This commit is contained in:
Ludovic CANDELLIER
2022-07-04 00:35:43 +02:00
parent eadea3958d
commit 01f56204b7
9 changed files with 50 additions and 49 deletions

View File

@@ -17,7 +17,6 @@ class Customer extends Authenticatable
protected $guarded = ['id'];
protected $table = 'shop_customers';
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'settings', 'last_login'];
protected $hidden = ['password', 'remember_token'];
protected $casts = ['email_verified_at' => 'datetime'];
@@ -26,11 +25,6 @@ class Customer extends Authenticatable
return $this->hasMany(CustomerAddress::class);
}
public function invoices()
{
return $this->hasMany(Invoice::class);
}
public function customer_deliveries()
{
return $this->hasMany(CustomerDelivery::class);
@@ -41,9 +35,9 @@ class Customer extends Authenticatable
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
}
public function deliveries2()
public function invoices()
{
return $this->hasManyThrough(Delivery::class, CustomerDelivery::class);
return $this->hasMany(Invoice::class);
}
public function orders()
@@ -62,5 +56,4 @@ class Customer extends Authenticatable
{
$this->notify(new ResetPassword($token));
}
}

View File

@@ -18,4 +18,24 @@ class CustomerAddress extends Model
{
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);
}
}