minor fixes
This commit is contained in:
@@ -60,7 +60,7 @@ class ArticleNature extends Model implements HasMedia
|
||||
return $query->whereIn($this->table.'.id', $ids);
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_MAX, 60, 32)->keepOriginalImageFormat()->nonQueued();
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_MAX, 360, 192)->keepOriginalImageFormat()->nonQueued();
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
@@ -20,13 +20,13 @@ class CustomerDelivery extends Model
|
||||
return $this->belongsTo(Delivery::class);
|
||||
}
|
||||
|
||||
public function scopeByCustomer($query, $customer_id)
|
||||
public function scopeByCustomer($query, $customerId)
|
||||
{
|
||||
return $query->where($this->table.'.customer_id', $customer_id);
|
||||
return $query->where($this->table.'.customer_id', $customerId);
|
||||
}
|
||||
|
||||
public function scopeByDelivery($query, $customer_id)
|
||||
public function scopeByDelivery($query, $deliveryId)
|
||||
{
|
||||
return $query->where($this->table.'.delivery_id', $customer_id);
|
||||
return $query->where($this->table.'.delivery_id', $deliveryId);
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Models/Shop/CustomerSaleChannel.php
Normal file
36
app/Models/Shop/CustomerSaleChannel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class CustomerSaleChannel extends Model
|
||||
{
|
||||
use SoftDeletes, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_customer_sale_channels';
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function sale_channel()
|
||||
{
|
||||
return $this->belongsTo(SaleChannel::class);
|
||||
}
|
||||
|
||||
public function scopeByCustomer($query, $customerId)
|
||||
{
|
||||
return $query->where($this->table.'.customer_id', $customerId);
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $saleChannelId)
|
||||
{
|
||||
return $query->where($this->table.'.sale_channel_id', $saleChannelId);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,11 @@ class Delivery extends Model
|
||||
return $query->where($this->table.'.at_house', 1);
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query)
|
||||
{
|
||||
return $query->where($this->table.'.sale_channel_id', 1);
|
||||
}
|
||||
|
||||
public function scopeManaged($query)
|
||||
{
|
||||
return $query->byPublic(0);
|
||||
|
||||
@@ -10,6 +10,16 @@ class SaleChannel extends Model
|
||||
|
||||
protected $table = 'shop_sale_channels';
|
||||
|
||||
public function customer_sale_channels()
|
||||
{
|
||||
return $this->hasMany(CustomerSaleChannel::class);
|
||||
}
|
||||
|
||||
public function customers()
|
||||
{
|
||||
return $this->belongsToMany(Customer::class, CustomerSaleChannel::class)->wherePivotNull('deleted_at');
|
||||
}
|
||||
|
||||
public function deliveries()
|
||||
{
|
||||
return $this->hasMany(Delivery::class);
|
||||
@@ -29,4 +39,9 @@ class SaleChannel extends Model
|
||||
{
|
||||
return $query->where($this->table.'.code', $code);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user