Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 19 |
| RejectedBillItem | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
56.00 | |
0.00% |
0 / 19 |
| rejectedBill | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| injectCommodityName | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 16 |
|||
| getQualityLabelAttribute | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| <?php | |
| namespace App; | |
| use Illuminate\Database\Eloquent\Collection; | |
| use Illuminate\Database\Eloquent\Model; | |
| use Illuminate\Database\Eloquent\SoftDeletes; | |
| /** | |
| * @property mixed rejectedBill | |
| */ | |
| class RejectedBillItem extends Model | |
| { | |
| use SoftDeletes; | |
| protected $fillable=['id_rejected_bill','barcode_goods','name_goods','amount','id_quality_label', | |
| 'batch_number','validity_at','made_at','is_checked','remark','is_loaded']; | |
| protected $appends = ['quality_label']; | |
| public function rejectedBill(){ | |
| return $this->belongsTo('App\RejectedBill', 'id_rejected_bill', 'id'); | |
| } | |
| public function injectCommodityName(){ | |
| if(!$this['name_goods'])return; | |
| $barcode=$this['barcode_goods']; | |
| $name=$this['name_goods']; | |
| $commodity=Commodity::where('barcode', $barcode)->first(); | |
| if($commodity){ | |
| if($commodity['name']!=$name){ | |
| $commodity['name']=$name; | |
| } | |
| if(!$commodity['owner_name']){ | |
| $commodity['owner_name']=$this->rejectedBill->owner->name; | |
| } | |
| $commodity->update(); | |
| } | |
| else{ | |
| $commodity = new Commodity(); | |
| $commodity['barcode']=$barcode; | |
| $commodity['name']=$name; | |
| $commodity['owner_name']=$this->rejectedBill->owner->name; | |
| $commodity->save(); | |
| } | |
| } | |
| public function getQualityLabelAttribute(){ | |
| $label=QualityLabel::find($this['id_quality_label']); | |
| return $label['name']; | |
| } | |
| } |