| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- class Process extends Model
- {
- protected $fillable=[
- 'code','owner_id','bill_type','wms_code','process_method_id','operation_code',
- 'unit_price','status','commodity_id','amount','completed_amount','remark','created_at','updated_at'
- ];
- protected $appends=[
- 'owner_name','process_method_name','commodity_name','commodity_barcode'
- ];
- public function owner(){
- return $this->belongsTo('App\Owner','owner_id','id');
- }
- public function processMethod(){
- return $this->belongsTo('App\ProcessMethod','process_method_id','id');
- }
- public function commodity(){
- return $this->belongsTo('App\Commodity','commodity_id','id');
- }
- public function tutorials(){
- return $this->belongsToMany('App\Tutorial','process_tutorial','process_id','tutorial_id');
- }
- public function getOwnerNameAttribute()
- {
- return $this['owner']? $this['owner']['name']:null;
- }
- public function getProcessMethodNameAttribute()
- {
- return $this['processMethod']? $this['processMethod']['name']:null;
- }
- public function getCommodityNameAttribute()
- {
- return $this['commodity']? $this['commodity']['name']:null;
- }
- public function getCommodityBarcodeAttribute()
- {
- return $this['commodity']? $this['commodity']['barcode']:null;
- }
- }
|