<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use Carbon\Carbon;
use Illuminate\Support\Facades\Storage;

class Piatto extends \App\Models\AbstractModels\AbstractPiatto
{
    /**
     * Allergeni collegati tramite pivot `piatto_allergene`.
     * Usiamo la relazione per precompilare l'Editor e per salvare via sync.
     */
    public function allergeni()
    {
        return $this->belongsToMany(
            Allergene::class,
            'piatto_allergene',
            'piatto_id',
            'allergene_id'
        );
    }
}
