minor fixes

This commit is contained in:
ludo
2023-12-09 21:02:28 +01:00
parent b5da5fc881
commit 2a429e4163
49 changed files with 448 additions and 266 deletions

View File

@@ -21,7 +21,6 @@ class Customer extends Authenticatable
protected $casts = ['email_verified_at' => 'datetime'];
public function delivery_addresses()
{
return $this->addresses()->byDelivery();
@@ -31,7 +30,6 @@ class Customer extends Authenticatable
{
return $this->addresses()->byInvoicing();
}
public function addresses()
{
@@ -43,11 +41,21 @@ class Customer extends Authenticatable
return $this->hasMany(CustomerDelivery::class);
}
public function customer_sale_channels()
{
return $this->hasMany(CustomerSaleChannel::class);
}
public function deliveries()
{
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
}
public function sale_channels()
{
return $this->belongsToMany(SaleChannel::class, CustomerSaleChannel::class)->wherePivotNull('deleted_at');
}
public function invoices()
{
return $this->hasMany(Invoice::class);
@@ -58,6 +66,13 @@ class Customer extends Authenticatable
return $this->hasMany(Order::class);
}
public function scopeBySaleChannel($query, $saleChannelId)
{
return $query->whereHas('sale_channels', function ($query) use ($saleChannelId) {
return $query->byId($saleChannelId);
});
}
public function sendEmailVerificationNotification()
{
if (config('boilerplate.auth.verify_email')) {