<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Produit extends Model
{
    use HasFactory, SoftDeletes;
    protected $dates = ['deleted_at'];
    
    protected $fillable = ['nom','document','description','image'];

    
    public function diapos(){
        return $this->hasMany(Media::class);    
    }

    public function diapo()
    {
        return $this->hasMany(Media::class,'produit_id','id');
    }
   
    public function remove_categorie($category_id){
        $this->categorie()->detach($category_id);         
    }
    
    public function categories()
    {
     return $this->belongsToMany(Categorie::class,'categorie_produit');                 
    }
   
}
