OwlCyberSecurity - MANAGER
Edit File: SheetResource.php
<?php namespace App\Filament\Resources; use App\Filament\Resources\SheetResource\Pages; use App\Models\Exchanges; use App\Models\Sheet; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Actions\EditAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; class SheetResource extends Resource { protected static ?string $model = Sheet::class; protected static ?string $navigationIcon = 'heroicon-o-table-cells'; protected static ?string $modelLabel = 'شیت'; protected static ?string $pluralModelLabel = 'شیت ها'; protected static ?string $slug = 'sheets'; protected static ?string $navigationGroup = 'تنظیمات'; protected static ?int $navigationSort = 4; public static function form(Form $form): Form { return $form->schema([ Section::make()->schema([ TextInput::make('name')->label('نام')->required(), TextInput::make('ratio')->label('نرخ تبدیل')->required()->numeric(), Grid::make(3)->schema([ TextInput::make('cost_transfer_usa_to_aue')->label('هزینه ارسال از امریکا به امارات')->numeric()->default(0), Select::make('exchange_id_transfer_usa_to_aue')->label('نوع ارز ارسال از امریکا به امارات')->options(Exchanges::all()->pluck('name', 'id'))->default(1), TextInput::make('exchange_transfer_usa_to_aue')->label('نرخ ارز ارسال از امریکا به امارات')->numeric()->default(0), ]), Grid::make(3)->schema([ TextInput::make('cost_delivery_to_aue')->label('هزینه تحویل امارات')->numeric()->default(0), Select::make('exchange_id_delivery_to_aue')->label('نوع ارز تحویل امارات')->options(Exchanges::all()->pluck('name', 'id'))->default(1), TextInput::make('exchange_delivery_to_aue')->label('نرخ ارز تحویل امارات')->numeric()->default(0), ]), Grid::make(3)->schema([ TextInput::make('cost_office_aue')->label('هزینه دفتر امارات')->numeric()->default(0), Select::make('exchange_id_office_aue')->label('نوع ارز دفتر امارات')->options(Exchanges::all()->pluck('name', 'id'))->default(1), TextInput::make('exchange_office_aue')->label('نرخ ارز دفتر امارات')->numeric()->default(0), ]), TextInput::make('cost_iran_customs')->label('هزینه گمرک ایران')->required()->numeric(), TextInput::make('cost_transfer_to_tehran')->label('هزینه حمل تا تهران')->required()->numeric(), TextInput::make('cost_store')->label('هزینه انبار')->required()->numeric(), TextInput::make('cost_store_to_office')->label('هزینه انبار تا دفتر')->required()->numeric(), TextInput::make('cost_post')->label('هزینه پست و بسته بندی ارسال به مشتری')->numeric()->default(0), ]), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->label('نام'), TextColumn::make('ratio')->label('نرخ تبدیل'), TextColumn::make('cost_transfer_usa_to_aue')->label('هزینه ارسال از امریکا به امارات'), TextColumn::make('exchangeIdTransfer.name')->label('نوع ارز ارسال از امریکا به امارات'), TextColumn::make('exchange_transfer_usa_to_aue')->label('نرخ ارز ارسال از امریکا به امارات'), TextColumn::make('sumFinalCost')->label('مجموع هزینه ها')->money('irr') ->getStateUsing(function (Sheet $record): float { return $record->cost_transfer_usa_to_aue + $record->exchange_office_aue; }), ]) ->filters([ // ]) ->actions([ EditAction::make(), ]) ->bulkActions([ ]) ->emptyStateActions([ CreateAction::make(), ]); } public static function getPages(): array { return [ 'index' => Pages\ListSheets::route('/'), 'create' => Pages\CreateSheet::route('/create'), 'edit' => Pages\EditSheet::route('/{record}/edit'), ]; } public static function canViewAny(): bool { return auth()->user()->can('sheets::view'); } }