Version 2.0
This commit is contained in:
@@ -6,14 +6,19 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
#[Fillable(['name', 'email', 'phone', 'address', 'status'])]
|
||||
class Customer extends Model
|
||||
{
|
||||
public function products(): BelongsToMany
|
||||
/**
|
||||
* Các căn hộ khách hàng sở hữu (qua HĐ Ownership active)
|
||||
*/
|
||||
public function ownedProducts(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'customer_product')
|
||||
->withPivot('purchase_date')
|
||||
return $this->belongsToMany(Product::class, 'contracts')
|
||||
->wherePivot('category', 'ownership')
|
||||
->wherePivot('status', 'active')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user