first commit
This commit is contained in:
63
app/Models/Table.php
Normal file
63
app/Models/Table.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
class Table extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'source_database_id',
|
||||
'schema_name',
|
||||
'table_name',
|
||||
'comment',
|
||||
'options',
|
||||
'last_checked_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'last_checked_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function sourceDatabase(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SourceDatabase::class);
|
||||
}
|
||||
|
||||
public function columns(): HasMany
|
||||
{
|
||||
return $this->hasMany(Column::class);
|
||||
}
|
||||
|
||||
public function indexes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Index::class);
|
||||
}
|
||||
|
||||
public function foreignKeys(): HasMany
|
||||
{
|
||||
return $this->hasMany(ForeignKey::class);
|
||||
}
|
||||
|
||||
public function schemaChanges(): HasMany
|
||||
{
|
||||
return $this->hasMany(SchemaChange::class);
|
||||
}
|
||||
|
||||
public function migrationScheduleTables(): HasMany
|
||||
{
|
||||
return $this->hasMany(MigrationScheduleTable::class);
|
||||
}
|
||||
|
||||
public function getFullNameAttribute(): string
|
||||
{
|
||||
return "{$this->schema_name}.{$this->table_name}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user