- Fixed database relationships: LlmRequest now properly uses gateway_user_id instead of user_id - Updated Models: GatewayUser and LlmRequest relationships corrected - Removed User->llmRequests relationship (admin users don't have LLM requests) - Simplified Dashboard: Now shows Gateway User statistics instead of admin users - Removed obsolete Budgets management pages (budgets handled directly in gateway_users) - Removed User Budgets admin section (redundant with gateway_users management) - Fixed view errors: Added null-checks for user_id in keys views - Updated navigation: Removed Budget and User Budget links - Updated routes: Cleaned up unused BudgetController and UserManagementController routes - Simplified StatisticsService: Focus on gateway_users and basic metrics only
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class LlmRequest extends Model
|
|
{
|
|
protected $fillable = [
|
|
'gateway_user_id',
|
|
'provider',
|
|
'model',
|
|
'request_payload',
|
|
'response_payload',
|
|
'prompt_tokens',
|
|
'completion_tokens',
|
|
'total_tokens',
|
|
'response_time_ms',
|
|
'prompt_cost',
|
|
'completion_cost',
|
|
'total_cost',
|
|
'status',
|
|
'error_message',
|
|
'http_status',
|
|
'ip_address',
|
|
'user_agent',
|
|
'request_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'request_payload' => 'array',
|
|
'response_payload' => 'array',
|
|
'prompt_tokens' => 'integer',
|
|
'completion_tokens' => 'integer',
|
|
'total_tokens' => 'integer',
|
|
'response_time_ms' => 'integer',
|
|
'prompt_cost' => 'decimal:6',
|
|
'completion_cost' => 'decimal:6',
|
|
'total_cost' => 'decimal:6',
|
|
'http_status' => 'integer',
|
|
];
|
|
|
|
public function gatewayUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(GatewayUser::class, 'gateway_user_id', 'user_id');
|
|
}
|
|
|
|
public function isSuccess(): bool
|
|
{
|
|
return $this->status === 'success';
|
|
}
|
|
|
|
public function isFailed(): bool
|
|
{
|
|
return $this->status === 'failed';
|
|
}
|
|
}
|