- Any-LLM Gateway setup with Docker Compose - Laravel 11 admin interface with Livewire - Dashboard with usage statistics and charts - Gateway Users management with budget tracking - API Keys management with revocation - Budget templates with assignment - Usage Logs with filtering and CSV export - Model Pricing management with calculator - PostgreSQL database integration - Complete authentication system for admins
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Budget extends Model
|
|
{
|
|
protected $primaryKey = 'budget_id';
|
|
public $incrementing = false;
|
|
protected $keyType = 'string';
|
|
|
|
protected $fillable = [
|
|
'budget_id',
|
|
'max_budget',
|
|
'budget_duration_sec',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'max_budget' => 'double',
|
|
'budget_duration_sec' => 'integer',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function gatewayUsers()
|
|
{
|
|
return $this->hasMany(GatewayUser::class, 'budget_id', 'budget_id');
|
|
}
|
|
|
|
public function getMaxBudgetFormattedAttribute()
|
|
{
|
|
return '$' . number_format($this->max_budget, 2);
|
|
}
|
|
|
|
public function getDurationHumanAttribute()
|
|
{
|
|
if (!$this->budget_duration_sec) return 'No limit';
|
|
|
|
$days = floor($this->budget_duration_sec / 86400);
|
|
$hours = floor(($this->budget_duration_sec % 86400) / 3600);
|
|
|
|
return "{$days}d {$hours}h";
|
|
}
|
|
}
|