الملفات
Tabeley-v0.0a/app/Models/ReservationStatusHistory.php
Abdul Kareem 5764dd03e4
فشلت بعض الفحوصات
Deploy Backend / deploy (push) Has been cancelled
backend: align API/models with current PostgreSQL schema
2026-02-19 19:43:11 +03:00

54 أسطر
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Schema;
class ReservationStatusHistory extends Model
{
use HasFactory;
public $timestamps = false;
protected static ?string $resolvedTable = null;
protected $fillable = [
'reservation_id',
'old_status',
'new_status',
'changed_by_user_id',
'note',
'created_at',
];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = self::tableName();
}
public static function tableName(): string
{
if (self::$resolvedTable !== null) {
return self::$resolvedTable;
}
self::$resolvedTable = Schema::hasTable('reservation_status_histories')
? 'reservation_status_histories'
: 'reservation_status_history';
return self::$resolvedTable;
}
public function reservation()
{
return $this->belongsTo(Reservation::class);
}
public function changedBy()
{
return $this->belongsTo(User::class, 'changed_by_user_id');
}
}