restore composer.json, add mysqli extension

This commit is contained in:
2026-04-15 17:02:52 +05:00
commit 77cf56a348
4317 changed files with 1397107 additions and 0 deletions

66
app/Models/OrderProducts.php Executable file
View File

@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Order;
use App\Models\Product;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @package App\Models
* @property integer $id
* @property integer $order_id
* @property integer $product_id
* @property integer $count
* @property $price
* @property integer $discount
*
* @property-read Order $order
* @property-read Product $product
*
* @property-read float $total_price
* @property-read float $final_price
*/
class OrderProducts extends Model
{
protected $guarded = ['id'];
public $timestamps = false;
protected $casts = [
'order_id' => 'integer',
'product_id' => 'integer',
'count' => 'integer',
];
public function order(): BelongsTo
{
return $this->belongsTo(Order::class)->withTrashed();
}
public function getCount()
{
return $this->count;
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class)->withTrashed();
}
public function getFinalPriceAttribute(): float
{
if (!empty($this->discount)) {
return $this->discount;
} else {
return $this->price;
}
}
public function getTotalPriceAttribute(): float
{
$price = $this->discount ?? $this->price;
return $price * $this->count;
}
}