28 lines
733 B
PHP
28 lines
733 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Customer extends Model
|
|
{
|
|
use HasUuids, HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
// Ép kiểu để Laravel tự động dịch JSON thành Mảng khi hiển thị lên Form
|
|
protected $casts = [
|
|
'address' => 'array',
|
|
'dob' => 'date',
|
|
];
|
|
|
|
public function contracts()
|
|
{
|
|
return $this->belongsToMany(Contract::class, 'contract_customers')
|
|
->using(ContractCustomer::class)
|
|
->withPivot('id', 'role', 'transfer_order')
|
|
->withTimestamps();
|
|
}
|
|
} |