change homepages to contents, add new methods to deliveries and sale_channels by customer
This commit is contained in:
@@ -7,11 +7,13 @@ use App\Notifications\VerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use AuthenticationLogable, Notifiable, SoftDeletes;
|
||||
use AuthenticationLogable, HasRelationships, Notifiable, RevisionableTrait, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
@@ -48,7 +50,10 @@ class Customer extends Authenticatable
|
||||
|
||||
public function deliveries()
|
||||
{
|
||||
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
|
||||
return $this->hasManyDeepFromRelations(
|
||||
$this->sale_channels(),
|
||||
(new SaleChannel())->deliveries())
|
||||
->whereNull('shop_customer_sale_channels.deleted_at');
|
||||
}
|
||||
|
||||
public function sale_channels()
|
||||
@@ -66,6 +71,11 @@ class Customer extends Authenticatable
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $saleChannelId)
|
||||
{
|
||||
return $query->whereHas('sale_channels', function ($query) use ($saleChannelId) {
|
||||
|
||||
Reference in New Issue
Block a user