'datetime', 'prompt_tokens' => 'integer', 'completion_tokens' => 'integer', 'total_tokens' => 'integer', 'cost' => 'double', ]; } public function gatewayUser() { return $this->belongsTo(GatewayUser::class, 'user_id', 'user_id'); } public function apiKey() { return $this->belongsTo(ApiKey::class, 'api_key_id', 'id'); } public function scopeSuccess($query) { return $query->where('status', 'success'); } public function scopeFailed($query) { return $query->where('status', '!=', 'success'); } public function scopeToday($query) { return $query->whereDate('timestamp', today()); } public function scopeDateRange($query, $start, $end) { return $query->whereBetween('timestamp', [$start, $end]); } public function getCostFormattedAttribute() { return $this->cost ? '$' . number_format($this->cost, 4) : 'N/A'; } }