<?php

namespace App;

use App\Filters\MaterialFilters;
use Illuminate\Database\Eloquent\Model;
use App\Traits\ModelLogChanging;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Material extends Model
{
    use ModelLogChanging;

    protected $fillable = ['name','code'];

    public function supplier():BelongsToMany
    {
        return $this->belongsToMany(Supplier::class,'material_suppliers','material_id','supplier_id');
    }

    public function scopeFilter($query, $filters)
    {
        return $filters->apply($query);
    }
}
