33 lines
674 B
PHP
33 lines
674 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CustomerDelivery extends Model
|
|
{
|
|
protected $guarded = ['id'];
|
|
|
|
protected $table = 'shop_customer_deliveries';
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function delivery()
|
|
{
|
|
return $this->belongsTo(Delivery::class);
|
|
}
|
|
|
|
public function scopeByCustomer($query, $customerId)
|
|
{
|
|
return $query->where($this->table.'.customer_id', $customerId);
|
|
}
|
|
|
|
public function scopeByDelivery($query, $deliveryId)
|
|
{
|
|
return $query->where($this->table.'.delivery_id', $deliveryId);
|
|
}
|
|
}
|