Supplier.php 712 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Traits\ModelLogChanging;
  6. use Illuminate\Database\Eloquent\Relations\BelongsToMany;
  7. use Illuminate\Database\Eloquent\SoftDeletes;
  8. class Supplier extends Model
  9. {
  10. use ModelLogChanging;
  11. use ModelTimeFormat;
  12. use SoftDeletes;
  13. protected $fillable = ['name','contact_man','phone','invoice_title','bank','bank_account','opening_bank'];
  14. public function material():BelongsToMany
  15. {
  16. return $this->belongsToMany(Material::class,'material_suppliers','supplier_id','material_id');
  17. }
  18. public function scopeFilter($query,$filters)
  19. {
  20. return $filters->apply($query);
  21. }
  22. }