This commit is contained in:
Bozhidar Slaveykov 2024-04-02 19:27:14 +03:00
parent 50f2d19d2b
commit 50d0567dbf
5 changed files with 171 additions and 1 deletions

View file

@ -0,0 +1,120 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\HostingPlanResource\Pages;
use App\Filament\Resources\HostingPlanResource\RelationManagers;
use App\Models\HostingPlan;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class HostingPlanResource extends Resource
{
protected static ?string $model = HostingPlan::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->required(),
Forms\Components\TextInput::make('slug')
->label('Slug')
->required(),
Forms\Components\Textarea::make('description')
->label('Description'),
Forms\Components\TextInput::make('disk_space')
->label('Disk Space'),
Forms\Components\TextInput::make('bandwidth')
->label('Bandwidth'),
Forms\Components\TextInput::make('databases')
->label('Databases'),
Forms\Components\TextInput::make('ftp_accounts')
->label('FTP Accounts'),
Forms\Components\TextInput::make('email_accounts')
->label('Email Accounts'),
Forms\Components\TextInput::make('subdomains')
->label('Subdomains'),
Forms\Components\TextInput::make('parked_domains')
->label('Parked Domains'),
Forms\Components\TextInput::make('addon_domains')
->label('Addon Domains'),
Forms\Components\TextInput::make('ssl_certificates')
->label('SSL Certificates'),
Forms\Components\TextInput::make('daily_backups')
->label('Daily Backups'),
Forms\Components\TextInput::make('free_domain')
->label('Free Domain'),
Forms\Components\Textarea::make('additional_services')
->label('Additional Services'),
Forms\Components\Textarea::make('features')
->label('Features'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->label('Name'),
Tables\Columns\TextColumn::make('slug')
->searchable()
->label('Slug'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListHostingPlans::route('/'),
'create' => Pages\CreateHostingPlan::route('/create'),
'edit' => Pages\EditHostingPlan::route('/{record}/edit'),
];
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\HostingPlanResource\Pages;
use App\Filament\Resources\HostingPlanResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateHostingPlan extends CreateRecord
{
protected static string $resource = HostingPlanResource::class;
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\HostingPlanResource\Pages;
use App\Filament\Resources\HostingPlanResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditHostingPlan extends EditRecord
{
protected static string $resource = HostingPlanResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\HostingPlanResource\Pages;
use App\Filament\Resources\HostingPlanResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListHostingPlans extends ListRecords
{
protected static string $resource = HostingPlanResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View file

@ -34,5 +34,5 @@ class HostingPlan extends Model
'features' => 'array',
'limitations' => 'array',
];
}