Files
opensem/app/Models/Shop/CustomerDelivery.php
Ludovic CANDELLIER 0879b0abf0 add shipping rules
2023-07-16 14:45:42 +02:00

33 lines
678 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, $customer_id)
{
return $query->where($this->table.'.customer_id', $customer_id);
}
public function scopeByDelivery($query, $customer_id)
{
return $query->where($this->table.'.delivery_id', $customer_id);
}
}