| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- class ProcessesContent extends Model
- {
- use ModelTimeFormat;
- protected $fillable=[
- 'process_id','bill_type','commodity_id','wms_code','amount','type'
- ];
- protected $appends=[
- 'commodity_name',
- 'sign_mark',
- ];
- public function process(){
- return $this->belongsTo('App\Process','process_id','id');
- }
- public function commodity(){
- return $this->belongsTo('App\Commodity','commodity_id','id');
- }
- public function sign(){
- return $this->hasOne('App\Sign','signable_id','id')
- ->where('signable_type','processes_contents')->where('field','commodity_name');
- }
- public function getCommodityNameAttribute()
- {
- return $this['commodity']? $this['commodity']['name']:null;
- }
- public function getSignMarkAttribute()
- {
- return $this['sign']? $this['sign']['mark']:null;
- }
- }
|