45 lines
903 B
PHP
45 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class SchemaChange extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'table_id',
|
|
'change_type',
|
|
'old_value',
|
|
'new_value',
|
|
'description',
|
|
'is_applied',
|
|
'detected_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'old_value' => 'array',
|
|
'new_value' => 'array',
|
|
'is_applied' => 'boolean',
|
|
'detected_at' => 'datetime',
|
|
];
|
|
|
|
public function table(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Table::class);
|
|
}
|
|
|
|
public function scopePending($query)
|
|
{
|
|
return $query->where('is_applied', false);
|
|
}
|
|
|
|
public function scopeApplied($query)
|
|
{
|
|
return $query->where('is_applied', true);
|
|
}
|
|
}
|