Laravel 11 + Livewire 3/Volt + Alpine.js + Tailwind app for household budget planning, transaction tracking, and financial dashboards. - Multi-tenant households with member invites - Plan: monthly/yearly budget per category with overrides - Suivi: transaction log with running balance (desktop + mobile quick-entry) - Dashboard: budget vs tracked breakdown + Chart.js donuts - Flux: Sankey diagram of income allocation - WCAG 2.1 AA color tokens, dark mode, accessible tables/forms - 50 Pest tests Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
44 lines
956 B
PHP
44 lines
956 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\CategoryType;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Category extends Model
|
|
{
|
|
protected $fillable = ['household_id', 'name', 'type', 'position'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => CategoryType::class,
|
|
];
|
|
}
|
|
|
|
public function household(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Household::class);
|
|
}
|
|
|
|
public function budgetLines(): HasMany
|
|
{
|
|
return $this->hasMany(BudgetLine::class);
|
|
}
|
|
|
|
public function transactions(): HasMany
|
|
{
|
|
return $this->hasMany(Transaction::class);
|
|
}
|
|
|
|
public function scopeOfType(Builder $query, CategoryType $type): Builder
|
|
{
|
|
return $query->where('type', $type);
|
|
}
|
|
}
|