48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
use App\Enums\RecordStatusEnum;
|
|
use App\Models\Traits\HasLocalizedName;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Support\Facades\Session;
|
|
use App\Traits\AuditLogTrait;
|
|
|
|
class Building extends BaseModel
|
|
{
|
|
public $timestamps = false;
|
|
use HasFactory;
|
|
use HasLocalizedName;
|
|
use AuditLogTrait;
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
|
|
protected $appends = ['name'];
|
|
|
|
protected $primaryKey = 'id';
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
'code', 'name_en','name_kh', 'description', 'organization_id',
|
|
BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD,
|
|
BaseModel::DELETED_AT_FIELD, BaseModel::DELETED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
|
];
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
}
|
|
|
|
public function organization(){
|
|
return $this->belongsTo(Organization::class, 'organization_id', 'id');
|
|
}
|
|
|
|
public function rooms(){
|
|
return $this->hasMany(Room::class, 'building_id', 'id');
|
|
}
|
|
|
|
}
|