ProcessesContent.php 670 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. class ProcessesContent extends Model
  6. {
  7. use ModelTimeFormat;
  8. protected $fillable=[
  9. 'process_id','bill_type','commodity_id','wms_code','amount','type'
  10. ];
  11. protected $appends=[
  12. 'commodity_name',
  13. ];
  14. public function process(){
  15. return $this->belongsTo('App\Process','process_id','id');
  16. }
  17. public function commodity(){
  18. return $this->belongsTo('App\Commodity','commodity_id','id');
  19. }
  20. public function getCommodityNameAttribute()
  21. {
  22. return $this['commodity']? $this['commodity']['name']:null;
  23. }
  24. }