123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
-
- namespace App\Filament\Company\Resources\Common;
-
- use App\Filament\Company\Resources\Common\ClientResource\Pages;
- use App\Filament\Forms\Components\CreateCurrencySelect;
- use App\Models\Common\Client;
- use Filament\Forms;
- use Filament\Forms\Form;
- use Filament\Resources\Resource;
- use Filament\Tables;
- use Filament\Tables\Table;
-
- class ClientResource extends Resource
- {
- protected static ?string $model = Client::class;
-
- public static function form(Form $form): Form
- {
- return $form
- ->schema([
- Forms\Components\Section::make('General Information')
- ->schema([
- Forms\Components\TextInput::make('name')
- ->label('Client')
- ->required()
- ->maxLength(255),
- CreateCurrencySelect::make('currency_code')
- ->disabledOn('edit')
- ->relationship('currency', 'name'),
- Forms\Components\TextInput::make('account_number')
- ->maxLength(255),
- Forms\Components\TextInput::make('website')
- ->maxLength(255),
- Forms\Components\Textarea::make('notes')
- ->columnSpanFull(),
- ])->columns(),
- Forms\Components\Section::make('Billing')
- ->relationship('billingAddress')
- ->schema([
- Forms\Components\TextInput::make('address_line_1')
- ->label('Address Line 1')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('address_line_2')
- ->label('Address Line 2')
- ->maxLength(255),
- Forms\Components\TextInput::make('city')
- ->label('City')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('state')
- ->label('State')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('postal_code')
- ->label('Postal Code / Zip Code')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('country')
- ->label('Country')
- ->required()
- ->maxLength(255),
- ])->columns(),
- Forms\Components\Section::make('Shipping')
- ->relationship('shippingAddress')
- ->schema([
- Forms\Components\TextInput::make('recipient')
- ->label('Recipient')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('address_line_1')
- ->label('Address Line 1')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('address_line_2')
- ->label('Address Line 2')
- ->maxLength(255),
- Forms\Components\TextInput::make('city')
- ->label('City')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('state')
- ->label('State')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('postal_code')
- ->label('Postal Code / Zip Code')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('country')
- ->label('Country')
- ->required()
- ->maxLength(255),
- Forms\Components\TextInput::make('phone')
- ->label('Phone')
- ->required()
- ->maxLength(255),
- Forms\Components\Textarea::make('notes')
- ->label('Delivery Instructions')
- ->maxLength(255),
- ])->columns(),
- ]);
- }
-
- public static function table(Table $table): Table
- {
- return $table
- ->columns([
- Tables\Columns\TextColumn::make('company.name')
- ->numeric()
- ->sortable(),
- Tables\Columns\TextColumn::make('name')
- ->searchable(),
- Tables\Columns\TextColumn::make('currency_code')
- ->searchable(),
- Tables\Columns\TextColumn::make('account_number')
- ->searchable(),
- Tables\Columns\TextColumn::make('website')
- ->searchable(),
- ])
- ->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\ListClients::route('/'),
- 'create' => Pages\CreateClient::route('/create'),
- 'edit' => Pages\EditClient::route('/{record}/edit'),
- ];
- }
- }
|