30 lines
834 B
PHP
30 lines
834 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
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
|
|
{
|
|
/**
|
|
* 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, 'contracts')
|
|
->wherePivot('category', 'ownership')
|
|
->wherePivot('status', 'active')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function feedbacks(): HasMany
|
|
{
|
|
return $this->hasMany(Feedback::class);
|
|
}
|
|
}
|