*/ use HasFactory, LogsModelActivity; public string $log_message = 'BranchForm-add'; public string $log_source = 'manual'; protected $fillable = [ 'branch_id', 'floor', 'type', 'name', 'internal_ip', 'port', 'is_online', 'status', 'started_at', 'ended_at', ]; protected $attributes = [ 'type' => \App\Enums\RoomType::Unset, 'floor' => 1, 'is_online' => false, 'status' => \App\Enums\RoomStatus::Error, ]; //protected $hidden = [ // 'internal_ip', // 'port', //]; protected $casts = [ 'floor' => 'int', 'type' => \App\Enums\RoomType::class, 'name' => 'string', 'internal_ip' =>'string', 'port' => 'int', 'is_online' => 'boolean', 'status' => \App\Enums\RoomStatus::class, 'started_at' => 'datetime', 'ended_at' => 'datetime', ]; public function str_started_at(){ $str ="Not Set"; if($this->started_at !=null){ $str = $this->started_at; } return $str; } public function str_ended_at(){ $str ="Not Set"; if($this->ended_at !=null){ $str = $this->ended_at; } return $str; } public function branch() { return $this->belongsTo(Branch::class); } public function full_name(){ return $this->type->labelPowergridFilter().$this->name; } public function statusLogs() { return $this->hasMany(RoomStatusLog::class); } public function sessions() { return $this->hasMany(RoomSession::class); } }