You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClientResource.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. namespace App\Filament\Company\Resources\Common;
  3. use App\Filament\Company\Resources\Common\ClientResource\Pages;
  4. use App\Filament\Forms\Components\CreateCurrencySelect;
  5. use App\Models\Common\Client;
  6. use Filament\Forms;
  7. use Filament\Forms\Form;
  8. use Filament\Resources\Resource;
  9. use Filament\Tables;
  10. use Filament\Tables\Table;
  11. class ClientResource extends Resource
  12. {
  13. protected static ?string $model = Client::class;
  14. public static function form(Form $form): Form
  15. {
  16. return $form
  17. ->schema([
  18. Forms\Components\Section::make('General Information')
  19. ->schema([
  20. Forms\Components\TextInput::make('name')
  21. ->label('Client')
  22. ->required()
  23. ->maxLength(255),
  24. CreateCurrencySelect::make('currency_code')
  25. ->disabledOn('edit')
  26. ->relationship('currency', 'name'),
  27. Forms\Components\TextInput::make('account_number')
  28. ->maxLength(255),
  29. Forms\Components\TextInput::make('website')
  30. ->maxLength(255),
  31. Forms\Components\Textarea::make('notes')
  32. ->columnSpanFull(),
  33. ])->columns(),
  34. Forms\Components\Section::make('Billing')
  35. ->relationship('billingAddress')
  36. ->schema([
  37. Forms\Components\TextInput::make('address_line_1')
  38. ->label('Address Line 1')
  39. ->required()
  40. ->maxLength(255),
  41. Forms\Components\TextInput::make('address_line_2')
  42. ->label('Address Line 2')
  43. ->maxLength(255),
  44. Forms\Components\TextInput::make('city')
  45. ->label('City')
  46. ->required()
  47. ->maxLength(255),
  48. Forms\Components\TextInput::make('state')
  49. ->label('State')
  50. ->required()
  51. ->maxLength(255),
  52. Forms\Components\TextInput::make('postal_code')
  53. ->label('Postal Code / Zip Code')
  54. ->required()
  55. ->maxLength(255),
  56. Forms\Components\TextInput::make('country')
  57. ->label('Country')
  58. ->required()
  59. ->maxLength(255),
  60. ])->columns(),
  61. Forms\Components\Section::make('Shipping')
  62. ->relationship('shippingAddress')
  63. ->schema([
  64. Forms\Components\TextInput::make('recipient')
  65. ->label('Recipient')
  66. ->required()
  67. ->maxLength(255),
  68. Forms\Components\TextInput::make('address_line_1')
  69. ->label('Address Line 1')
  70. ->required()
  71. ->maxLength(255),
  72. Forms\Components\TextInput::make('address_line_2')
  73. ->label('Address Line 2')
  74. ->maxLength(255),
  75. Forms\Components\TextInput::make('city')
  76. ->label('City')
  77. ->required()
  78. ->maxLength(255),
  79. Forms\Components\TextInput::make('state')
  80. ->label('State')
  81. ->required()
  82. ->maxLength(255),
  83. Forms\Components\TextInput::make('postal_code')
  84. ->label('Postal Code / Zip Code')
  85. ->required()
  86. ->maxLength(255),
  87. Forms\Components\TextInput::make('country')
  88. ->label('Country')
  89. ->required()
  90. ->maxLength(255),
  91. Forms\Components\TextInput::make('phone')
  92. ->label('Phone')
  93. ->required()
  94. ->maxLength(255),
  95. Forms\Components\Textarea::make('notes')
  96. ->label('Delivery Instructions')
  97. ->maxLength(255),
  98. ])->columns(),
  99. ]);
  100. }
  101. public static function table(Table $table): Table
  102. {
  103. return $table
  104. ->columns([
  105. Tables\Columns\TextColumn::make('company.name')
  106. ->numeric()
  107. ->sortable(),
  108. Tables\Columns\TextColumn::make('name')
  109. ->searchable(),
  110. Tables\Columns\TextColumn::make('currency_code')
  111. ->searchable(),
  112. Tables\Columns\TextColumn::make('account_number')
  113. ->searchable(),
  114. Tables\Columns\TextColumn::make('website')
  115. ->searchable(),
  116. ])
  117. ->filters([
  118. //
  119. ])
  120. ->actions([
  121. Tables\Actions\EditAction::make(),
  122. ])
  123. ->bulkActions([
  124. Tables\Actions\BulkActionGroup::make([
  125. Tables\Actions\DeleteBulkAction::make(),
  126. ]),
  127. ]);
  128. }
  129. public static function getRelations(): array
  130. {
  131. return [
  132. //
  133. ];
  134. }
  135. public static function getPages(): array
  136. {
  137. return [
  138. 'index' => Pages\ListClients::route('/'),
  139. 'create' => Pages\CreateClient::route('/create'),
  140. 'edit' => Pages\EditClient::route('/{record}/edit'),
  141. ];
  142. }
  143. }