34 lines
679 B
PHP
34 lines
679 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class OrderDetail extends Model
|
|
{
|
|
protected $guarded = ['id'];
|
|
|
|
protected $table = 'shop_order_details';
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function offer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Offer::class);
|
|
}
|
|
|
|
public function scopeByOrder($query, $order_id)
|
|
{
|
|
return $query->where('order_id', $order_id);
|
|
}
|
|
|
|
public function scopeByOffer($query, $offer_id)
|
|
{
|
|
return $query->where('offer_id', $offer_id);
|
|
}
|
|
}
|