*/ use HasFactory, HasUuids; protected $table = 'workspace_ai_usages'; protected $fillable = [ 'account_id', 'workspace_id', 'user_id', 'post_id', 'type', 'provider', 'metadata', ]; protected function casts(): array { return [ 'type' => UsageType::class, 'metadata' => 'array', ]; } public function account(): BelongsTo { return $this->belongsTo(Account::class); } public static function monthlyCount(string $accountId, UsageType $type): int { return static::where('account_id', $accountId) ->where('type', $type) ->whereBetween('created_at', [now()->startOfMonth(), now()->endOfMonth()]) ->count(); } }