Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
25.00% |
1 / 4 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| PriceList | |
25.00% |
1 / 4 |
|
25.00% |
1 / 4 |
10.75 | |
0.00% |
0 / 1 |
| auditName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| group | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| product | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| category | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Models\admin\Product; |
| 6 | use App\Support\Auditable; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | /** |
| 10 | * One price rule for a customer group: either a product-specific or a |
| 11 | * whole-category rule, either an explicit price or a percent off, from a |
| 12 | * minimum quantity upward. Resolved by App\Services\Pricing\PriceService — |
| 13 | * this model itself is just data. |
| 14 | */ |
| 15 | class PriceList extends Model |
| 16 | { |
| 17 | use Auditable; |
| 18 | |
| 19 | protected $fillable = ['customer_group_id', 'product_id', 'category_id', 'min_qty', 'price', 'percent_off']; |
| 20 | |
| 21 | protected $casts = [ |
| 22 | 'min_qty' => 'integer', |
| 23 | 'price' => 'decimal:2', |
| 24 | 'percent_off' => 'decimal:2', |
| 25 | ]; |
| 26 | |
| 27 | protected function auditName(): string |
| 28 | { |
| 29 | return 'price_list'; |
| 30 | } |
| 31 | |
| 32 | public function group() |
| 33 | { |
| 34 | return $this->belongsTo(CustomerGroup::class, 'customer_group_id'); |
| 35 | } |
| 36 | |
| 37 | public function product() |
| 38 | { |
| 39 | return $this->belongsTo(Product::class); |
| 40 | } |
| 41 | |
| 42 | public function category() |
| 43 | { |
| 44 | return $this->belongsTo(Category::class); |
| 45 | } |
| 46 | } |