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