Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SaleCard | |
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| customer | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| product | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| brand | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| color | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| size | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sumByCustomerID | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Models\admin\Product; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | class SaleCard extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $table = 'sale_cards'; |
| 14 | |
| 15 | protected $fillable = [ |
| 16 | 'customer_id', |
| 17 | 'product_id', |
| 18 | 'qty', |
| 19 | 'brand_id', |
| 20 | 'color_id', |
| 21 | 'size_id', |
| 22 | 'selling_price', |
| 23 | 'total_price', |
| 24 | ]; |
| 25 | |
| 26 | public function customer() |
| 27 | { |
| 28 | return $this->belongsTo(Customer::class); |
| 29 | } |
| 30 | |
| 31 | public function product() |
| 32 | { |
| 33 | return $this->belongsTo(Product::class); |
| 34 | } |
| 35 | |
| 36 | public function brand() |
| 37 | { |
| 38 | return $this->belongsTo(Brand::class); |
| 39 | } |
| 40 | |
| 41 | public function color() |
| 42 | { |
| 43 | return $this->belongsTo(Color::class); |
| 44 | } |
| 45 | |
| 46 | public function size() |
| 47 | { |
| 48 | return $this->belongsTo(Size::class); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Repository Methods Start |
| 53 | * */ |
| 54 | public static function sumByCustomerID($customer_id) |
| 55 | { |
| 56 | |
| 57 | return self::query() |
| 58 | ->where('customer_id', '=', $customer_id) |
| 59 | ->sum('total_price') ?? 0; |
| 60 | |
| 61 | } |
| 62 | } |