- Remove old any-llm related files (Dockerfile, config.yml, web/, setup-laravel.sh) - Update README.md with new Laravel LLM Gateway documentation - Keep docker-compose.yml with laravel-llm container names - Clean project structure for Laravel-only implementation
70 lines
1.5 KiB
PHP
70 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UsageLog extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'usage_logs';
|
|
protected $primaryKey = 'request_id';
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'request_id',
|
|
'user_id',
|
|
'api_key',
|
|
'model',
|
|
'provider',
|
|
'endpoint',
|
|
'prompt_tokens',
|
|
'completion_tokens',
|
|
'total_tokens',
|
|
'cost',
|
|
'status',
|
|
'error_message',
|
|
'timestamp',
|
|
'metadata',
|
|
];
|
|
|
|
protected $casts = [
|
|
'prompt_tokens' => 'integer',
|
|
'completion_tokens' => 'integer',
|
|
'total_tokens' => 'integer',
|
|
'cost' => 'decimal:6',
|
|
'timestamp' => 'datetime',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(GatewayUser::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
public function gatewayUser()
|
|
{
|
|
return $this->belongsTo(GatewayUser::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
public function apiKey()
|
|
{
|
|
return $this->belongsTo(ApiKey::class, 'api_key', 'token');
|
|
}
|
|
|
|
// Scopes
|
|
public function scopeSuccess($query)
|
|
{
|
|
return $query->where('status', 'success');
|
|
}
|
|
|
|
public function scopeFailed($query)
|
|
{
|
|
return $query->where('status', 'failed');
|
|
}
|
|
}
|