116 lines
4.0 KiB
PHP
116 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\PlanResource\Pages;
|
|
use App\Filament\Resources\PlanResource\RelationManagers;
|
|
use App\Models\Plan;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\KeyValue;
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\Section;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Forms\Set;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Columns\BooleanColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Illuminate\Support\Str;
|
|
use phpDocumentor\Reflection\Types\Boolean;
|
|
|
|
class PlanResource extends Resource
|
|
{
|
|
protected static ?string $model = Plan::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Web Master';
|
|
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Section::make('Plan Information')
|
|
->description('Add a new plan')
|
|
->schema([
|
|
TextInput::make('name')->label('Page Name')
|
|
->required(),
|
|
TextInput::make('description'),
|
|
TextInput::make('product_id')->required(),
|
|
TextInput::make('pricing_id')->required(),
|
|
TextInput::make('shoppy_product_id')->nullable(),
|
|
TextInput::make('oxapay_link')->nullable(),
|
|
TextInput::make('price')->numeric()->required(),
|
|
TextInput::make('mailbox_limit')->numeric()->required(),
|
|
Select::make('monthly_billing')->options([
|
|
1 => 'Monthly',
|
|
0 => 'Yearly',
|
|
])->required(),
|
|
Select::make('accept_stripe')->options([
|
|
1 => 'Activate',
|
|
0 => 'Disable',
|
|
])->required(),
|
|
Select::make('accept_shoppy')->options([
|
|
1 => 'Activate',
|
|
0 => 'Disable',
|
|
])->required(),
|
|
Select::make('accept_oxapay')->options([
|
|
1 => 'Activate',
|
|
0 => 'Disable',
|
|
])->required(),
|
|
KeyValue::make('details')
|
|
->label('Plan Details (Optional)')
|
|
->keyPlaceholder('Name')
|
|
->valuePlaceholder('Content')
|
|
->reorderable(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')->label('Name'),
|
|
TextColumn::make('product_id')->label('Product'),
|
|
TextColumn::make('pricing_id')->label('Pricing'),
|
|
TextColumn::make('price')->label('Price'),
|
|
BooleanColumn::make('monthly_billing')->label('Monthly Billing'),
|
|
])
|
|
->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\ListPlans::route('/'),
|
|
'create' => Pages\CreatePlan::route('/create'),
|
|
'edit' => Pages\EditPlan::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|