Rename project from any-llm to laravel-llm
- 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
This commit is contained in:
@@ -2,47 +2,61 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Budget extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'budgets';
|
||||
protected $primaryKey = 'budget_id';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'budget_id',
|
||||
'max_budget',
|
||||
'budget_duration_sec',
|
||||
'name',
|
||||
'monthly_limit',
|
||||
'daily_limit',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
protected $casts = [
|
||||
'monthly_limit' => 'decimal:2',
|
||||
'daily_limit' => 'decimal:2',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get formatted max budget display
|
||||
*/
|
||||
public function getMaxBudgetFormattedAttribute(): string
|
||||
{
|
||||
return [
|
||||
'max_budget' => 'double',
|
||||
'budget_duration_sec' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
if ($this->monthly_limit) {
|
||||
return '$' . number_format($this->monthly_limit, 2);
|
||||
}
|
||||
if ($this->daily_limit) {
|
||||
return '$' . number_format($this->daily_limit, 2) . '/day';
|
||||
}
|
||||
return 'Unlimited';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get human-readable duration
|
||||
*/
|
||||
public function getDurationHumanAttribute(): string
|
||||
{
|
||||
if ($this->monthly_limit && $this->daily_limit) {
|
||||
return 'Monthly';
|
||||
}
|
||||
if ($this->daily_limit && !$this->monthly_limit) {
|
||||
return 'Daily';
|
||||
}
|
||||
return 'Unlimited';
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user