Shows how to build nested resources using restaurant menus with categories and dishes. Both categories and dishes can be reordered directly in the Filament table.
One-time payment
Sign in with GitHub to buy
Sign in first, then complete your $9 checkout.
30-day money-back guarantee
In this project, we have two Models:
Here are the contents of both models with fields and relationships defined.
app/Models/Category.php
use App\Observers\CategoryObserver;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\HasMany;use Illuminate\Database\Eloquent\Attributes\ObservedBy; #[ObservedBy(CategoryObserver::class)]class Category extends Model{ use HasFactory; protected $fillable = ['name', 'position']; public function dishes(): HasMany { return $this->hasMany(Dish::class); }}
app/Models/Dish.php
use App\Observers\DishObserver;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsTo;use Illuminate\Database\Eloquent\Attributes\ObservedBy; #[ObservedBy(DishObserver::class)]class Dish extends Model{ // ...
Next, we will: