50 lines
943 B
PHP
50 lines
943 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class CustomerAddress extends Model
|
|
{
|
|
use SoftDeletes;
|
|
protected $guarded = ['id'];
|
|
|
|
protected $table = 'shop_customer_addresses';
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function orders()
|
|
{
|
|
return $this->hasMany(Order::class);
|
|
}
|
|
|
|
public function scopeByCustomer($query, $id)
|
|
{
|
|
return $query->where('customer_id', $id);
|
|
}
|
|
|
|
public function scopeByDelivery($query)
|
|
{
|
|
return $query->byType(1);
|
|
}
|
|
|
|
public function scopeByInvoicing($query)
|
|
{
|
|
return $query->byType(2);
|
|
}
|
|
|
|
public function scopeByType($query, $id)
|
|
{
|
|
return $query->where('type', $id);
|
|
}
|
|
|
|
public function scopeDefault($query)
|
|
{
|
|
return $query->where('priority', 1);
|
|
}
|
|
}
|