This commit is contained in:
Bozhidar Slaveykov 2023-11-27 23:22:23 +02:00
parent 6166c96de5
commit e788c4f49a
2 changed files with 14 additions and 10 deletions

View file

@ -12,6 +12,7 @@ use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
class WebsiteResource extends Resource
{
@ -25,11 +26,14 @@ class WebsiteResource extends Resource
{
return $form
->schema([
Forms\Components\TextInput::make('server_name')
->autofocus()
Forms\Components\TextInput::make('domain')
->required()
->unique()
->placeholder('example.com'),
->suffixIcon('heroicon-m-globe-alt'),
Forms\Components\TextInput::make('root')
->default('/'),
]);
}
@ -37,7 +41,7 @@ class WebsiteResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('server_name')
Tables\Columns\TextColumn::make('domain')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('root')

View file

@ -13,13 +13,13 @@ class Website extends Model
protected $fillable = [
'file',
'server_name',
'domain',
'root'
];
protected $schema = [
'file' => 'string',
'server_name' => 'string',
'domain' => 'string',
'root' => 'string'
];
@ -30,7 +30,7 @@ class Website extends Model
static::creating(function ($model) {
$createWebsite = ShellApi::callBin('website-create', [
$model->server_name,
$model->domain,
'bobkata'
]);
@ -42,7 +42,7 @@ class Website extends Model
static::deleting(function ($model) {
$deleteWebsite = ShellApi::callBin('website-delete', [
$model->server_name
$model->domain
]);
if (empty($deleteWebsite)) {
return false;
@ -67,7 +67,7 @@ class Website extends Model
if (isset($website['file'])) {
$rows[] = [
'file' => $website['file'],
'server_name' => $website['server_name'],
'domain' => $website['server_name'],
'root' => $website['root']
];
}