OwlCyberSecurity - MANAGER
Edit File: ProductOfferCategoryResource.php
<?php namespace App\Filament\Resources; use App\Filament\Resources\ProductOfferCategoryResource\Pages; use App\Filament\Resources\ProductOfferCategoryResource\RelationManagers; use App\Helpers\Convertors; use App\Models\ProductOfferCategories; use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; use Closure; class ProductOfferCategoryResource extends Resource { protected static ?string $model = ProductOfferCategories::class; protected static ?string $navigationIcon = 'heroicon-o-list-bullet'; protected static ?string $slug = 'product-offer-category'; protected static ?string $modelLabel = 'دسته بندی'; protected static ?string $pluralModelLabel = 'دسته بندی محصولات '; protected static ?int $navigationSort = 4; protected static ?string $navigationGroup = 'پیشنهاد ها'; public static function form(Form $form): Form { return $form ->schema([ Grid::make(3)->schema([ Grid::make(1)->schema([ Grid::make(1)->schema([ TextInput::make('title')->label('عنوان')->columnSpan(2)->required(), ]), ]), Section::make()->schema([ TextInput::make('slug')->label('اسلاگ')->rules([ function () { return function (string $attribute, $value, Closure $fail) { if ($value != Convertors::createSlug($value, '-')) { $fail('فرمت اسلاگ صحیح نمیباشد'); } }; }, ])->unique(ignoreRecord: true)->maxLength(255)->required(), FileUpload::make('image_name')->image()->label('تصویر سایز : 100*100')->imageEditor()->required(), TextInput::make('priority')->label('اولویت نمایش')->required()->numeric()->minValue(1)->maxValue(1000), Toggle::make('is_show')->label('وضعیت نمایش')->required(), Toggle::make('target')->label('لینک خارج از سایت')->required(), ])->columnSpan(1), ]), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('title')->label('عنوان')->searchable(), TextColumn::make('slug')->label('اسلاگ')->searchable(), IconColumn::make('is_show')->label('وضعیت نمایش')->boolean(), TextColumn::make('priority')->label('اولویت نمایش با عدد کمتر است')->sortable(), TextColumn::make('created_at')->label('ایجاد در')->dateTime(), TextColumn::make('updated_at')->label('آخرین برروزرسانی')->dateTime(), ]) ->filters([ ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ])->defaultSort('updated_at', 'desc'); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListProductOfferCategories::route('/'), 'create' => Pages\CreateProductOfferCategory::route('/create'), 'edit' => Pages\EditProductOfferCategory::route('/{record}/edit'), ]; } public static function canViewAny(): bool { return auth()->user()->can('product-offer::view'); } }