OwnerMaterial.php 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Traits\LogModelChanging;
  6. class OwnerMaterial extends Model
  7. {
  8. use LogModelChanging;
  9. use ModelTimeFormat;
  10. protected $table = 'owner_material';
  11. protected $fillable = ['owner_id','material_id','material_code','size','special','specification','initiator'];
  12. public function owner()
  13. {
  14. return $this->belongsTo(Owner::class);
  15. }
  16. public function material()
  17. {
  18. return $this->belongsTo(Material::class);
  19. }
  20. public function initiator()
  21. {
  22. return $this->belongsTo(User::class,'initiator','id');
  23. }
  24. public function file()
  25. {
  26. return $this->hasOne(UploadFile::class,'table_id','id')->where('table_name','owner_material');
  27. }
  28. public function scopeFilter($query,$filters)
  29. {
  30. return $filters->apply($query);
  31. }
  32. }