Skip to content

Commit

Permalink
add config to custom resource
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 12, 2024
1 parent defd3b3 commit 18752f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
23 changes: 23 additions & 0 deletions config/filament-accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,28 @@
"invitation" => \TomatoPHP\FilamentAccounts\Models\TeamInvitation::class,
"membership" => \TomatoPHP\FilamentAccounts\Models\Membership::class,
"resource" => \TomatoPHP\FilamentAccounts\Filament\Resources\TeamResource::class,
],

/**
* Accounts Relations Managers
*
* you can set selected relations to show in account resource
*/
"relations" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\AccountRelations::class,


/**
* Accounts Resource Builder
*
* you can change the form, table, actions and filters of account resource by using filament-helpers class commands
*
* link: https://github.com/tomatophp/filament-helpers
*/
"accounts" => [
"form" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Forms\AccountsForm::class,
"table" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Tables\AccountsTable::class,
"actions" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Actions\AccountsActions::class,
"filters" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Filters\AccountsFilters::class,
"pages" => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Pages\AccountPages::class,
]
];
8 changes: 4 additions & 4 deletions src/Filament/Resources/AccountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ public static function getLabel(): ?string

public static function form(Form $form): Form
{
return AccountsForm::make($form);
return config('filament-accounts.accounts.form') ? config('filament-accounts.accounts.form')::make($form) : AccountsForm::make($form);
}

public static function table(Table $table): Table
{
return AccountsTable::make($table);
return config('filament-accounts.accounts.table') ? config('filament-accounts.accounts.table')::make($table) : AccountsTable::make($table);
}

public static function getRelations(): array
{
return AccountReleations::get();
return config('filament-accounts.relations') ? config('filament-accounts.relations')::get() : AccountReleations::get();
}

public static function getPages(): array
{
return [
return config('filament-accounts.accounts.pages') ? config('filament-accounts.accounts.pages')::routes() : [
'index' => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Pages\ListAccounts::route('/'),
'edit' => \TomatoPHP\FilamentAccounts\Filament\Resources\AccountResource\Pages\EditAccount::route('/{record}/edit')
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public function table(Table $table): Table
return $table
->headerActions($actions->toArray())
->columns($colums->toArray())
->filters(AccountsFilters::make())
->actions(AccountsTableActions::make())
->filters(config('filament-accounts.accounts.filters') ? config('filament-accounts.accounts.filters')::make() : AccountsFilters::make())
->actions(config('filament-accounts.accounts.actions') ? config('filament-accounts.accounts.actions')::make() : AccountsTableActions::make())
->defaultSort('id', 'desc')
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down

0 comments on commit 18752f5

Please sign in to comment.