ProcessesContent.php 760 B

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