mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Remove table action classes
This commit is contained in:
@@ -5,6 +5,15 @@ namespace App\Livewire;
|
||||
use App\Models\Post;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
@@ -13,15 +22,6 @@ use Filament\Support\Enums\Alignment;
|
||||
use Filament\Support\Enums\FontFamily;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\IconPosition;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\CheckboxColumn;
|
||||
use Filament\Tables\Columns\ColorColumn;
|
||||
use Filament\Tables\Columns\ColumnGroup;
|
||||
|
||||
@@ -23,9 +23,7 @@ CreateAction::make()
|
||||
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\CreateAction`:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\CreateAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -23,9 +23,7 @@ EditAction::make()
|
||||
If you want to edit table rows, you can use the `Filament\Tables\Actions\EditAction` instead:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\EditAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -168,10 +166,7 @@ EditAction::make()
|
||||
At any time, you may call `$action->halt()` from inside a lifecycle hook or mutation method, which will halt the entire saving process:
|
||||
|
||||
```php
|
||||
use App\Models\Post;
|
||||
use Filament\Notifications\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use App\Models\Post;use Filament\Actions\EditAction;use Filament\Notifications\Actions\Action;use Filament\Notifications\Notification;
|
||||
|
||||
EditAction::make()
|
||||
->before(function (EditAction $action, Post $record) {
|
||||
|
||||
@@ -23,9 +23,7 @@ ViewAction::make()
|
||||
If you want to view table rows, you can use the `Filament\Tables\Actions\ViewAction` instead:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\ViewAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -53,4 +51,4 @@ ViewAction::make()
|
||||
|
||||
return $data;
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
@@ -16,10 +16,7 @@ DeleteAction::make()
|
||||
If you want to delete table rows, you can use the `Filament\Tables\Actions\DeleteAction` instead, or `Filament\Tables\Actions\DeleteBulkAction` to delete multiple at once:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\BulkActionGroup;use Filament\Actions\DeleteAction;use Filament\Actions\DeleteBulkAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -16,8 +16,7 @@ ReplicateAction::make()
|
||||
If you want to replicate table rows, you can use the `Filament\Tables\Actions\ReplicateAction` instead:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ReplicateAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\ReplicateAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -16,10 +16,7 @@ ForceDeleteAction::make()
|
||||
If you want to force-delete table rows, you can use the `Filament\Tables\Actions\ForceDeleteAction` instead, or `Filament\Tables\Actions\ForceDeleteBulkAction` to force-delete multiple at once:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\ForceDeleteAction;
|
||||
use Filament\Tables\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\BulkActionGroup;use Filament\Actions\ForceDeleteAction;use Filament\Actions\ForceDeleteBulkAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -16,10 +16,7 @@ RestoreAction::make()
|
||||
If you want to restore table rows, you can use the `Filament\Tables\Actions\RestoreAction` instead, or `Filament\Tables\Actions\RestoreBulkAction` to restore multiple at once:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\RestoreAction;
|
||||
use Filament\Tables\Actions\RestoreBulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\BulkActionGroup;use Filament\Actions\RestoreAction;use Filament\Actions\RestoreBulkAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -39,9 +39,7 @@ ImportAction::make()
|
||||
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\ImportAction`:
|
||||
|
||||
```php
|
||||
use App\Filament\Imports\ProductImporter;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Imports\ProductImporter;use Filament\Actions\ImportAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -37,9 +37,7 @@ ExportAction::make()
|
||||
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\ExportAction`:
|
||||
|
||||
```php
|
||||
use App\Filament\Exports\ProductExporter;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Exports\ProductExporter;use Filament\Actions\ExportAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -54,9 +52,7 @@ public function table(Table $table): Table
|
||||
Or if you want to add it as a table bulk action, so that the user can choose which rows to export, they can use `Filament\Tables\Actions\ExportBulkAction`:
|
||||
|
||||
```php
|
||||
use App\Filament\Exports\ProductExporter;
|
||||
use Filament\Tables\Actions\ExportBulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Exports\ProductExporter;use Filament\Actions\ExportBulkAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
namespace Filament\Actions;
|
||||
|
||||
class BulkAction extends Action
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
namespace Filament\Actions;
|
||||
|
||||
/**
|
||||
* @deprecated Use `\Filament\Tables\Actions\Action` instead, with the `button()` method.
|
||||
* @deprecated Use `\Filament\Actions\Action` instead, with the `button()` method.
|
||||
* @see Action
|
||||
*/
|
||||
class ButtonAction extends Action
|
||||
@@ -5,6 +5,8 @@ namespace Filament\Actions\Concerns;
|
||||
use AnourValar\EloquentSerialize\Facades\EloquentSerializeFacade;
|
||||
use Closure;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\ExportAction as ExportTableAction;
|
||||
use Filament\Actions\ExportBulkAction as ExportTableBulkAction;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
@@ -18,8 +20,6 @@ use Filament\Schema\Components\Fieldset;
|
||||
use Filament\Schema\Components\Split;
|
||||
use Filament\Schema\Components\Utilities\Get;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Actions\ExportAction as ExportTableAction;
|
||||
use Filament\Tables\Actions\ExportBulkAction as ExportTableBulkAction;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use Illuminate\Foundation\Bus\PendingChain;
|
||||
|
||||
@@ -6,6 +6,7 @@ use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Action as TableAction;
|
||||
use Filament\Actions\ImportAction;
|
||||
use Filament\Actions\ImportAction as ImportTableAction;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Jobs\ImportCsv;
|
||||
@@ -19,7 +20,6 @@ use Filament\Schema\Components\Utilities\Get;
|
||||
use Filament\Schema\Components\Utilities\Set;
|
||||
use Filament\Support\ChunkIterator;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Actions\ImportAction as ImportTableAction;
|
||||
use Illuminate\Bus\PendingBatch;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
@@ -8,9 +8,13 @@ use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Schema\Contracts\HasSchemas;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CreateAction extends Action
|
||||
{
|
||||
@@ -51,7 +55,18 @@ class CreateAction extends Action
|
||||
$this->action(function (array $arguments, ComponentContainer $form): void {
|
||||
$model = $this->getModel();
|
||||
|
||||
$record = $this->process(function (array $data, HasActions & HasSchemas $livewire) use ($model): Model {
|
||||
$record = $this->process(function (array $data, HasActions & HasSchemas $livewire, ?Table $table) use ($model): Model {
|
||||
$relationship = $table?->getRelationship() ?? $this->getRelationship();
|
||||
|
||||
$pivotData = [];
|
||||
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$pivotColumns = $relationship->getPivotColumns();
|
||||
|
||||
$pivotData = Arr::only($data, $pivotColumns);
|
||||
$data = Arr::except($data, $pivotColumns);
|
||||
}
|
||||
|
||||
if ($translatableContentDriver = $livewire->makeFilamentTranslatableContentDriver()) {
|
||||
$record = $translatableContentDriver->makeRecord($model, $data);
|
||||
} else {
|
||||
@@ -59,14 +74,23 @@ class CreateAction extends Action
|
||||
$record->fill($data);
|
||||
}
|
||||
|
||||
if ($relationship = $this->getRelationship()) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
$relationship->save($record);
|
||||
if (
|
||||
(! $relationship) ||
|
||||
$relationship instanceof HasManyThrough
|
||||
) {
|
||||
$record->save();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
$record->save();
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$relationship->save($record, $pivotData);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
$relationship->save($record);
|
||||
|
||||
return $record;
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
@@ -7,7 +7,10 @@ use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schema\Contracts\HasSchemas;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class EditAction extends Action
|
||||
{
|
||||
@@ -49,8 +52,29 @@ class EditAction extends Action
|
||||
});
|
||||
|
||||
$this->action(function (): void {
|
||||
$this->process(function (array $data, HasActions & HasSchemas $livewire, Model $record) {
|
||||
if ($translatableContentDriver = $livewire->makeFilamentTranslatableContentDriver()) {
|
||||
$this->process(function (array $data, HasActions & HasSchemas $livewire, Model $record, ?Table $table) {
|
||||
$relationship = $table?->getRelationship();
|
||||
|
||||
$translatableContentDriver = $livewire->makeFilamentTranslatableContentDriver();
|
||||
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$pivot = $record->{$relationship->getPivotAccessor()};
|
||||
|
||||
$pivotColumns = $relationship->getPivotColumns();
|
||||
$pivotData = Arr::only($data, $pivotColumns);
|
||||
|
||||
if (count($pivotColumns)) {
|
||||
if ($translatableContentDriver) {
|
||||
$translatableContentDriver->updateRecord($pivot, $pivotData);
|
||||
} else {
|
||||
$pivot->update($pivotData);
|
||||
}
|
||||
}
|
||||
|
||||
$data = Arr::except($data, $pivotColumns);
|
||||
}
|
||||
|
||||
if ($translatableContentDriver) {
|
||||
$translatableContentDriver->updateRecord($record, $data);
|
||||
} else {
|
||||
$record->update($data);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanExportRecords;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
namespace Filament\Actions;
|
||||
|
||||
/**
|
||||
* @deprecated Use `\Filament\Tables\Actions\Action` instead, with the `iconButton()` method.
|
||||
* @deprecated Use `\Filament\Actions\Action` instead, with the `iconButton()` method.
|
||||
* @see Action
|
||||
*/
|
||||
class IconButtonAction extends Action
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
namespace Filament\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
@@ -171,9 +171,7 @@ Forms\Components\TextInput::make('password')
|
||||
Resource classes contain a `table()` method that is used to build the table on the [List page](listing-records):
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
@@ -189,11 +187,11 @@ public static function table(Table $table): Table
|
||||
// ...
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
\Filament\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\BulkActionGroup::make([
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -402,8 +400,7 @@ This can be especially useful if you are using [simple resources](#simple-modal-
|
||||
To generate a URL for an action in the resource's table, you should pass the `tableAction` and `tableActionRecord` as URL parameters:
|
||||
|
||||
```php
|
||||
use App\Filament\Resources\CustomerResource;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use App\Filament\Resources\CustomerResource;use Filament\Actions\EditAction;
|
||||
|
||||
CustomerResource::getUrl(parameters: [
|
||||
'tableAction' => EditAction::getDefaultName(),
|
||||
|
||||
@@ -70,7 +70,6 @@ If your resource is simple, you may wish to view records in modals rather than o
|
||||
If your resource doesn't contain a `ViewAction`, you can add one to the `$table->actions()` array:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -80,7 +79,7 @@ public static function table(Table $table): Table
|
||||
// ...
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
\Filament\Actions\ViewAction::make(),
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ Alternatively, you may add soft deleting functionality to an existing resource.
|
||||
Firstly, you must update the resource:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
@@ -38,16 +35,16 @@ public static function table(Table $table): Table
|
||||
// You may add these actions to your table if you're using a simple
|
||||
// resource, or you just want to be able to delete records without
|
||||
// leaving the table.
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\ForceDeleteAction::make(),
|
||||
Tables\Actions\RestoreAction::make(),
|
||||
\Filament\Actions\DeleteAction::make(),
|
||||
\Filament\Actions\ForceDeleteAction::make(),
|
||||
\Filament\Actions\RestoreAction::make(),
|
||||
// ...
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
\Filament\Actions\BulkActionGroup::make([
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\ForceDeleteBulkAction::make(),
|
||||
\Filament\Actions\RestoreBulkAction::make(),
|
||||
// ...
|
||||
]),
|
||||
]);
|
||||
@@ -83,7 +80,6 @@ protected function getHeaderActions(): array
|
||||
By default, you can bulk-delete records in your table. You may also wish to delete single records, using a `DeleteAction`:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -94,7 +90,7 @@ public static function table(Table $table): Table
|
||||
])
|
||||
->actions([
|
||||
// ...
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
\Filament\Actions\DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -250,7 +250,6 @@ php artisan make:filament-relation-manager CategoryResource posts title --attach
|
||||
Alternatively, if you've already generated your resource, you can just add the actions to the `$table` arrays:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
@@ -261,16 +260,16 @@ public function table(Table $table): Table
|
||||
])
|
||||
->headerActions([
|
||||
// ...
|
||||
Tables\Actions\AttachAction::make(),
|
||||
\Filament\Actions\AttachAction::make(),
|
||||
])
|
||||
->actions([
|
||||
// ...
|
||||
Tables\Actions\DetachAction::make(),
|
||||
\Filament\Actions\DetachAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
\Filament\Actions\BulkActionGroup::make([
|
||||
// ...
|
||||
Tables\Actions\DetachBulkAction::make(),
|
||||
\Filament\Actions\DetachBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -281,7 +280,7 @@ public function table(Table $table): Table
|
||||
By default, as you search for a record to attach, options will load from the database via AJAX. If you wish to preload these options when the form is first loaded instead, you can use the `preloadRecordSelect()` method of `AttachAction`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AttachAction;
|
||||
|
||||
AttachAction::make()
|
||||
->preloadRecordSelect()
|
||||
@@ -292,8 +291,7 @@ AttachAction::make()
|
||||
When you attach record with the `Attach` button, you may wish to define a custom form to add pivot attributes to the relationship:
|
||||
|
||||
```php
|
||||
use Filament\Forms;
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AttachAction;use Filament\Forms;
|
||||
|
||||
AttachAction::make()
|
||||
->form(fn (AttachAction $action): array => [
|
||||
@@ -311,8 +309,7 @@ Please ensure that any pivot attributes are listed in the `withPivot()` method o
|
||||
You may want to scope the options available to `AttachAction`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Actions\AttachAction;use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
AttachAction::make()
|
||||
->recordSelectOptionsQuery(fn (Builder $query) => $query->whereBelongsTo(auth()->user()))
|
||||
@@ -323,7 +320,7 @@ AttachAction::make()
|
||||
By default, the options available to `AttachAction` will be searched in the `recordTitleAttribute()` of the table. If you wish to search across multiple columns, you can use the `recordSelectSearchColumns()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AttachAction;
|
||||
|
||||
AttachAction::make()
|
||||
->recordSelectSearchColumns(['title', 'description'])
|
||||
@@ -334,7 +331,7 @@ AttachAction::make()
|
||||
The `multiple()` method on the `AttachAction` component allows you to select multiple values:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AttachAction;
|
||||
|
||||
AttachAction::make()
|
||||
->multiple()
|
||||
@@ -345,8 +342,7 @@ AttachAction::make()
|
||||
You may customize the select field object that is used during attachment by passing a function to the `recordSelect()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AttachAction;use Filament\Forms\Components\Select;
|
||||
|
||||
AttachAction::make()
|
||||
->recordSelect(
|
||||
@@ -383,7 +379,6 @@ php artisan make:filament-relation-manager CategoryResource posts title --associ
|
||||
Alternatively, if you've already generated your resource, you can just add the actions to the `$table` arrays:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
@@ -394,16 +389,16 @@ public function table(Table $table): Table
|
||||
])
|
||||
->headerActions([
|
||||
// ...
|
||||
Tables\Actions\AssociateAction::make(),
|
||||
\Filament\Actions\AssociateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
// ...
|
||||
Tables\Actions\DissociateAction::make(),
|
||||
\Filament\Actions\DissociateAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
\Filament\Actions\BulkActionGroup::make([
|
||||
// ...
|
||||
Tables\Actions\DissociateBulkAction::make(),
|
||||
\Filament\Actions\DissociateBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -414,7 +409,7 @@ public function table(Table $table): Table
|
||||
By default, as you search for a record to associate, options will load from the database via AJAX. If you wish to preload these options when the form is first loaded instead, you can use the `preloadRecordSelect()` method of `AssociateAction`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Actions\AssociateAction;
|
||||
|
||||
AssociateAction::make()
|
||||
->preloadRecordSelect()
|
||||
@@ -425,8 +420,7 @@ AssociateAction::make()
|
||||
You may want to scope the options available to `AssociateAction`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Actions\AssociateAction;use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
AssociateAction::make()
|
||||
->recordSelectOptionsQuery(fn (Builder $query) => $query->whereBelongsTo(auth()->user()))
|
||||
@@ -437,7 +431,7 @@ AssociateAction::make()
|
||||
By default, the options available to `AssociateAction` will be searched in the `recordTitleAttribute()` of the table. If you wish to search across multiple columns, you can use the `recordSelectSearchColumns()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Actions\AssociateAction;
|
||||
|
||||
AssociateAction::make()
|
||||
->recordSelectSearchColumns(['title', 'description'])
|
||||
@@ -448,7 +442,7 @@ AssociateAction::make()
|
||||
The `multiple()` method on the `AssociateAction` component allows you to select multiple values:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Actions\AssociateAction;
|
||||
|
||||
AssociateAction::make()
|
||||
->multiple()
|
||||
@@ -459,8 +453,7 @@ AssociateAction::make()
|
||||
You may customize the select field object that is used during association by passing a function to the `recordSelect()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Actions\AssociateAction;use Filament\Forms\Components\Select;
|
||||
|
||||
AssociateAction::make()
|
||||
->recordSelect(
|
||||
@@ -479,7 +472,6 @@ php artisan make:filament-relation-manager CategoryResource posts title --view
|
||||
Alternatively, if you've already generated your relation manager, you can just add the `ViewAction` to the `$table->actions()` array:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
@@ -489,7 +481,7 @@ public function table(Table $table): Table
|
||||
// ...
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
\Filament\Actions\ViewAction::make(),
|
||||
// ...
|
||||
]);
|
||||
}
|
||||
@@ -506,10 +498,7 @@ php artisan make:filament-relation-manager CategoryResource posts title --soft-d
|
||||
Alternatively, you may add soft deleting functionality to an existing relation manager:
|
||||
|
||||
```php
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -525,16 +514,16 @@ public function table(Table $table): Table
|
||||
// ...
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\ForceDeleteAction::make(),
|
||||
Tables\Actions\RestoreAction::make(),
|
||||
\Filament\Actions\DeleteAction::make(),
|
||||
\Filament\Actions\ForceDeleteAction::make(),
|
||||
\Filament\Actions\RestoreAction::make(),
|
||||
// ...
|
||||
])
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\ForceDeleteBulkAction::make(),
|
||||
\Filament\Actions\RestoreBulkAction::make(),
|
||||
// ...
|
||||
]),
|
||||
]);
|
||||
@@ -840,16 +829,14 @@ public function table(Table $table): Table
|
||||
It is probably also useful to provide extra configuration on the relation manager if you wanted to add a header action to [create](#creating-related-records), [attach](#attaching-and-detaching-records), or [associate](#associating-and-dissociating-records) records in the relation manager:
|
||||
|
||||
```php
|
||||
use App\Filament\Resources\Blog\PostResource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\Blog\PostResource;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return PostResource::table($table)
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make(),
|
||||
Tables\Actions\AttachAction::make(),
|
||||
\Filament\Actions\CreateAction::make(),
|
||||
\Filament\Actions\AttachAction::make(),
|
||||
]);
|
||||
}
|
||||
```
|
||||
@@ -937,8 +924,7 @@ public function table(Table $table): Table
|
||||
If you're using `recordTitle()`, and you have an [associate action](#associating-and-dissociating-records) or [attach action](#attaching-and-detaching-records), you will also want to specify search columns for those actions:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Actions\AssociateAction;use Filament\Actions\AttachAction;
|
||||
|
||||
AssociateAction::make()
|
||||
->recordSelectSearchColumns(['title', 'id']);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Resources\Pages;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\Contracts\HasRecord;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -11,7 +12,6 @@ use Filament\Navigation\NavigationItem;
|
||||
use Filament\Resources\Concerns\HasTabs;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -105,7 +105,7 @@ class ListRecords extends Page implements Tables\Contracts\HasTable
|
||||
return static::getResource()::infolist($infolist);
|
||||
}
|
||||
|
||||
protected function configureCreateAction(CreateAction | Tables\Actions\CreateAction $action): void
|
||||
protected function configureCreateAction(CreateAction $action): void
|
||||
{
|
||||
$resource = static::getResource();
|
||||
|
||||
@@ -127,24 +127,24 @@ class ListRecords extends Page implements Tables\Contracts\HasTable
|
||||
protected function configureTableAction(Action $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof Tables\Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof Tables\Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof Tables\Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof Tables\Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof Tables\Actions\ViewAction => $this->configureViewAction($action),
|
||||
$action instanceof \Filament\Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof \Filament\Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof \Filament\Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof \Filament\Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof \Filament\Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof \Filament\Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof \Filament\Actions\ViewAction => $this->configureViewAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureDeleteAction(Tables\Actions\DeleteAction $action): void
|
||||
protected function configureDeleteAction(\Filament\Actions\DeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(fn (Model $record): bool => static::getResource()::canDelete($record));
|
||||
}
|
||||
|
||||
protected function configureEditAction(Tables\Actions\EditAction $action): void
|
||||
protected function configureEditAction(\Filament\Actions\EditAction $action): void
|
||||
{
|
||||
$resource = static::getResource();
|
||||
|
||||
@@ -157,25 +157,25 @@ class ListRecords extends Page implements Tables\Contracts\HasTable
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureForceDeleteAction(Tables\Actions\ForceDeleteAction $action): void
|
||||
protected function configureForceDeleteAction(\Filament\Actions\ForceDeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(fn (Model $record): bool => static::getResource()::canForceDelete($record));
|
||||
}
|
||||
|
||||
protected function configureReplicateAction(Tables\Actions\ReplicateAction $action): void
|
||||
protected function configureReplicateAction(\Filament\Actions\ReplicateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(fn (Model $record): bool => static::getResource()::canReplicate($record));
|
||||
}
|
||||
|
||||
protected function configureRestoreAction(Tables\Actions\RestoreAction $action): void
|
||||
protected function configureRestoreAction(\Filament\Actions\RestoreAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(fn (Model $record): bool => static::getResource()::canRestore($record));
|
||||
}
|
||||
|
||||
protected function configureViewAction(Tables\Actions\ViewAction $action): void
|
||||
protected function configureViewAction(\Filament\Actions\ViewAction $action): void
|
||||
{
|
||||
$resource = static::getResource();
|
||||
|
||||
@@ -192,26 +192,26 @@ class ListRecords extends Page implements Tables\Contracts\HasTable
|
||||
protected function configureTableBulkAction(BulkAction $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
$action instanceof \Filament\Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof \Filament\Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof \Filament\Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureDeleteBulkAction(Tables\Actions\DeleteBulkAction $action): void
|
||||
protected function configureDeleteBulkAction(\Filament\Actions\DeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static::getResource()::canDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureForceDeleteBulkAction(Tables\Actions\ForceDeleteBulkAction $action): void
|
||||
protected function configureForceDeleteBulkAction(\Filament\Actions\ForceDeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static::getResource()::canForceDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureRestoreBulkAction(Tables\Actions\RestoreBulkAction $action): void
|
||||
protected function configureRestoreBulkAction(\Filament\Actions\RestoreBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static::getResource()::canRestoreAny());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Resources\Pages;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Resources\Concerns\InteractsWithRelationshipTable;
|
||||
use Filament\Resources\RelationManagers\RelationGroup;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
@@ -10,7 +11,6 @@ use Filament\Resources\RelationManagers\RelationManagerConfiguration;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -136,84 +136,84 @@ class ManageRelatedRecords extends Page implements Tables\Contracts\HasTable
|
||||
protected function configureTableAction(Action $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\AssociateAction => $this->configureAssociateAction($action),
|
||||
$action instanceof Tables\Actions\AttachAction => $this->configureAttachAction($action),
|
||||
$action instanceof Tables\Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof Tables\Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof Tables\Actions\DetachAction => $this->configureDetachAction($action),
|
||||
$action instanceof Tables\Actions\DissociateAction => $this->configureDissociateAction($action),
|
||||
$action instanceof Tables\Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof Tables\Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof Tables\Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof Tables\Actions\ViewAction => $this->configureViewAction($action),
|
||||
$action instanceof \Filament\Actions\AssociateAction => $this->configureAssociateAction($action),
|
||||
$action instanceof \Filament\Actions\AttachAction => $this->configureAttachAction($action),
|
||||
$action instanceof \Filament\Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof \Filament\Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof \Filament\Actions\DetachAction => $this->configureDetachAction($action),
|
||||
$action instanceof \Filament\Actions\DissociateAction => $this->configureDissociateAction($action),
|
||||
$action instanceof \Filament\Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof \Filament\Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof \Filament\Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof \Filament\Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof \Filament\Actions\ViewAction => $this->configureViewAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureAssociateAction(Tables\Actions\AssociateAction $action): void
|
||||
protected function configureAssociateAction(\Filament\Actions\AssociateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canAssociate());
|
||||
}
|
||||
|
||||
protected function configureAttachAction(Tables\Actions\AttachAction $action): void
|
||||
protected function configureAttachAction(\Filament\Actions\AttachAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canAttach());
|
||||
}
|
||||
|
||||
protected function configureCreateAction(Tables\Actions\CreateAction $action): void
|
||||
protected function configureCreateAction(\Filament\Actions\CreateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canCreate())
|
||||
->form(fn (ComponentContainer $form): ComponentContainer => $this->form($form->columns(2)));
|
||||
}
|
||||
|
||||
protected function configureDeleteAction(Tables\Actions\DeleteAction $action): void
|
||||
protected function configureDeleteAction(\Filament\Actions\DeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canDelete($record));
|
||||
}
|
||||
|
||||
protected function configureDetachAction(Tables\Actions\DetachAction $action): void
|
||||
protected function configureDetachAction(\Filament\Actions\DetachAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canDetach($record));
|
||||
}
|
||||
|
||||
protected function configureDissociateAction(Tables\Actions\DissociateAction $action): void
|
||||
protected function configureDissociateAction(\Filament\Actions\DissociateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canDissociate($record));
|
||||
}
|
||||
|
||||
protected function configureEditAction(Tables\Actions\EditAction $action): void
|
||||
protected function configureEditAction(\Filament\Actions\EditAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canEdit($record))
|
||||
->form(fn (ComponentContainer $form): ComponentContainer => $this->form($form->columns(2)));
|
||||
}
|
||||
|
||||
protected function configureForceDeleteAction(Tables\Actions\ForceDeleteAction $action): void
|
||||
protected function configureForceDeleteAction(\Filament\Actions\ForceDeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canForceDelete($record));
|
||||
}
|
||||
|
||||
protected function configureReplicateAction(Tables\Actions\ReplicateAction $action): void
|
||||
protected function configureReplicateAction(\Filament\Actions\ReplicateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canReplicate($record));
|
||||
}
|
||||
|
||||
protected function configureRestoreAction(Tables\Actions\RestoreAction $action): void
|
||||
protected function configureRestoreAction(\Filament\Actions\RestoreAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canRestore($record));
|
||||
}
|
||||
|
||||
protected function configureViewAction(Tables\Actions\ViewAction $action): void
|
||||
protected function configureViewAction(\Filament\Actions\ViewAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire, Model $record): bool => $livewire->canView($record))
|
||||
@@ -224,40 +224,40 @@ class ManageRelatedRecords extends Page implements Tables\Contracts\HasTable
|
||||
protected function configureTableBulkAction(BulkAction $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\DetachBulkAction => $this->configureDetachBulkAction($action),
|
||||
$action instanceof Tables\Actions\DissociateBulkAction => $this->configureDissociateBulkAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
$action instanceof \Filament\Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof \Filament\Actions\DetachBulkAction => $this->configureDetachBulkAction($action),
|
||||
$action instanceof \Filament\Actions\DissociateBulkAction => $this->configureDissociateBulkAction($action),
|
||||
$action instanceof \Filament\Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof \Filament\Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureDeleteBulkAction(Tables\Actions\DeleteBulkAction $action): void
|
||||
protected function configureDeleteBulkAction(\Filament\Actions\DeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureDetachBulkAction(Tables\Actions\DetachBulkAction $action): void
|
||||
protected function configureDetachBulkAction(\Filament\Actions\DetachBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canDetachAny());
|
||||
}
|
||||
|
||||
protected function configureDissociateBulkAction(Tables\Actions\DissociateBulkAction $action): void
|
||||
protected function configureDissociateBulkAction(\Filament\Actions\DissociateBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canDissociateAny());
|
||||
}
|
||||
|
||||
protected function configureForceDeleteBulkAction(Tables\Actions\ForceDeleteBulkAction $action): void
|
||||
protected function configureForceDeleteBulkAction(\Filament\Actions\ForceDeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canForceDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureRestoreBulkAction(Tables\Actions\RestoreBulkAction $action): void
|
||||
protected function configureRestoreBulkAction(\Filament\Actions\RestoreBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (ManageRelatedRecords $livewire): bool => $livewire->canRestoreAny());
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Filament\Resources\RelationManagers;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Infolists;
|
||||
@@ -13,7 +14,6 @@ use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Support\Enums\IconPosition;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -186,84 +186,84 @@ class RelationManager extends Component implements Actions\Contracts\HasActions,
|
||||
protected function configureTableAction(Actions\Action $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\AssociateAction => $this->configureAssociateAction($action),
|
||||
$action instanceof Tables\Actions\AttachAction => $this->configureAttachAction($action),
|
||||
$action instanceof Tables\Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof Tables\Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof Tables\Actions\DetachAction => $this->configureDetachAction($action),
|
||||
$action instanceof Tables\Actions\DissociateAction => $this->configureDissociateAction($action),
|
||||
$action instanceof Tables\Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof Tables\Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof Tables\Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof Tables\Actions\ViewAction => $this->configureViewAction($action),
|
||||
$action instanceof Actions\AssociateAction => $this->configureAssociateAction($action),
|
||||
$action instanceof Actions\AttachAction => $this->configureAttachAction($action),
|
||||
$action instanceof Actions\CreateAction => $this->configureCreateAction($action),
|
||||
$action instanceof Actions\DeleteAction => $this->configureDeleteAction($action),
|
||||
$action instanceof Actions\DetachAction => $this->configureDetachAction($action),
|
||||
$action instanceof Actions\DissociateAction => $this->configureDissociateAction($action),
|
||||
$action instanceof Actions\EditAction => $this->configureEditAction($action),
|
||||
$action instanceof Actions\ForceDeleteAction => $this->configureForceDeleteAction($action),
|
||||
$action instanceof Actions\ReplicateAction => $this->configureReplicateAction($action),
|
||||
$action instanceof Actions\RestoreAction => $this->configureRestoreAction($action),
|
||||
$action instanceof Actions\ViewAction => $this->configureViewAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureAssociateAction(Tables\Actions\AssociateAction $action): void
|
||||
protected function configureAssociateAction(Actions\AssociateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canAssociate());
|
||||
}
|
||||
|
||||
protected function configureAttachAction(Tables\Actions\AttachAction $action): void
|
||||
protected function configureAttachAction(Actions\AttachAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canAttach());
|
||||
}
|
||||
|
||||
protected function configureCreateAction(Tables\Actions\CreateAction $action): void
|
||||
protected function configureCreateAction(Actions\CreateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canCreate())
|
||||
->form(fn (ComponentContainer $form): ComponentContainer => $this->form($form->columns(2)));
|
||||
}
|
||||
|
||||
protected function configureDeleteAction(Tables\Actions\DeleteAction $action): void
|
||||
protected function configureDeleteAction(Actions\DeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canDelete($record));
|
||||
}
|
||||
|
||||
protected function configureDetachAction(Tables\Actions\DetachAction $action): void
|
||||
protected function configureDetachAction(Actions\DetachAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canDetach($record));
|
||||
}
|
||||
|
||||
protected function configureDissociateAction(Tables\Actions\DissociateAction $action): void
|
||||
protected function configureDissociateAction(Actions\DissociateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canDissociate($record));
|
||||
}
|
||||
|
||||
protected function configureEditAction(Tables\Actions\EditAction $action): void
|
||||
protected function configureEditAction(Actions\EditAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canEdit($record))
|
||||
->form(fn (ComponentContainer $form): ComponentContainer => $this->form($form->columns(2)));
|
||||
}
|
||||
|
||||
protected function configureForceDeleteAction(Tables\Actions\ForceDeleteAction $action): void
|
||||
protected function configureForceDeleteAction(Actions\ForceDeleteAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canForceDelete($record));
|
||||
}
|
||||
|
||||
protected function configureReplicateAction(Tables\Actions\ReplicateAction $action): void
|
||||
protected function configureReplicateAction(Actions\ReplicateAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canReplicate($record));
|
||||
}
|
||||
|
||||
protected function configureRestoreAction(Tables\Actions\RestoreAction $action): void
|
||||
protected function configureRestoreAction(Actions\RestoreAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => (! $livewire->isReadOnly()) && $livewire->canRestore($record));
|
||||
}
|
||||
|
||||
protected function configureViewAction(Tables\Actions\ViewAction $action): void
|
||||
protected function configureViewAction(Actions\ViewAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire, Model $record): bool => $livewire->canView($record))
|
||||
@@ -274,40 +274,40 @@ class RelationManager extends Component implements Actions\Contracts\HasActions,
|
||||
protected function configureTableBulkAction(BulkAction $action): void
|
||||
{
|
||||
match (true) {
|
||||
$action instanceof Tables\Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\DetachBulkAction => $this->configureDetachBulkAction($action),
|
||||
$action instanceof Tables\Actions\DissociateBulkAction => $this->configureDissociateBulkAction($action),
|
||||
$action instanceof Tables\Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof Tables\Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
$action instanceof Actions\DeleteBulkAction => $this->configureDeleteBulkAction($action),
|
||||
$action instanceof Actions\DetachBulkAction => $this->configureDetachBulkAction($action),
|
||||
$action instanceof Actions\DissociateBulkAction => $this->configureDissociateBulkAction($action),
|
||||
$action instanceof Actions\ForceDeleteBulkAction => $this->configureForceDeleteBulkAction($action),
|
||||
$action instanceof Actions\RestoreBulkAction => $this->configureRestoreBulkAction($action),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected function configureDeleteBulkAction(Tables\Actions\DeleteBulkAction $action): void
|
||||
protected function configureDeleteBulkAction(Actions\DeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureDetachBulkAction(Tables\Actions\DetachBulkAction $action): void
|
||||
protected function configureDetachBulkAction(Actions\DetachBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canDetachAny());
|
||||
}
|
||||
|
||||
protected function configureDissociateBulkAction(Tables\Actions\DissociateBulkAction $action): void
|
||||
protected function configureDissociateBulkAction(Actions\DissociateBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canDissociateAny());
|
||||
}
|
||||
|
||||
protected function configureForceDeleteBulkAction(Tables\Actions\ForceDeleteBulkAction $action): void
|
||||
protected function configureForceDeleteBulkAction(Actions\ForceDeleteBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canForceDeleteAny());
|
||||
}
|
||||
|
||||
protected function configureRestoreBulkAction(Tables\Actions\RestoreBulkAction $action): void
|
||||
protected function configureRestoreBulkAction(Actions\RestoreBulkAction $action): void
|
||||
{
|
||||
$action
|
||||
->authorize(static fn (RelationManager $livewire): bool => (! $livewire->isReadOnly()) && $livewire->canRestoreAny());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Concerns\HasTranslatableLocaleOptions;
|
||||
use Filament\Actions\SelectAction;
|
||||
|
||||
class LocaleSwitcher extends SelectAction
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ It's possible to define as many filters as you need, and use any component from
|
||||
Filament's tables can use [Actions](../actions/overview). They are buttons that can be added to the [end of any table row](actions#row-actions), or even in the [header](actions#header-actions) of a table. For instance, you may want an action to "create" a new record in the header, and then "edit" and "delete" actions on each row. [Bulk actions](actions#bulk-actions) can be used to execute code when records in the table are selected.
|
||||
|
||||
```php
|
||||
use App\Models\Post;use Filament\Actions\Action;use Filament\Tables\Actions\BulkActionGroup;use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use App\Models\Post;use Filament\Actions\Action;use Filament\Actions\BulkActionGroup;use Filament\Actions\DeleteBulkAction;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -137,8 +137,7 @@ public function table(Table $table): Table
|
||||
Bulk actions may be created using the static `make()` method, passing its unique name. You should then pass a callback to `action()` which executes the task:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Filament\Actions\BulkAction;use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
BulkAction::make('delete')
|
||||
->requiresConfirmation()
|
||||
@@ -154,9 +153,7 @@ The function allows you to access the current table `$records` that are selected
|
||||
You may use a `BulkActionGroup` object to [group multiple bulk actions together](../actions/grouping-actions) in a dropdown. Any bulk actions that remain outside the `BulkActionGroup` will be rendered next to the dropdown's trigger button:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\BulkAction;use Filament\Actions\BulkActionGroup;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -178,9 +175,7 @@ public function table(Table $table): Table
|
||||
Alternatively, if all of your bulk actions are grouped, you can use the shorthand `groupedBulkActions()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\BulkAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -201,8 +196,7 @@ public function table(Table $table): Table
|
||||
You may deselect the records after a bulk action has been executed using the `deselectRecordsAfterCompletion()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Filament\Actions\BulkAction;use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
BulkAction::make('delete')
|
||||
->action(fn (Collection $records) => $records->each->delete())
|
||||
@@ -289,11 +283,7 @@ Filament includes several prebuilt actions and bulk actions that you can add to
|
||||
You may use an `ActionGroup` object to group multiple table actions together in a dropdown:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\ActionGroup;use Filament\Actions\DeleteAction;use Filament\Actions\EditAction;use Filament\Actions\ViewAction;use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
@@ -318,7 +308,7 @@ Out of the box, action group triggers have 3 styles - "button", "link", and "ico
|
||||
"Icon button" triggers are circular buttons with an [icon](#setting-the-action-group-button-icon) and no label. Usually, this is the default button style, but you can use it manually with the `iconButton()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -330,7 +320,7 @@ ActionGroup::make([
|
||||
"Button" triggers have a background color, label, and optionally an [icon](#setting-the-action-group-button-icon). You can switch to that style with the `button()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -344,7 +334,7 @@ ActionGroup::make([
|
||||
"Link" triggers have no background color. They must have a label and optionally an [icon](#setting-the-action-group-button-icon). They look like a link that you might find embedded within text. You can switch to that style with the `link()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -360,7 +350,7 @@ ActionGroup::make([
|
||||
You may set the [icon](https://blade-ui-kit.com/blade-icons?set=1#search) of the action group button using the `icon()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -374,7 +364,7 @@ ActionGroup::make([
|
||||
You may set the color of the action group button using the `color()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -388,8 +378,7 @@ ActionGroup::make([
|
||||
Buttons come in 3 sizes - `sm`, `md` or `lg`. You may set the size of the action group button using the `size()` method:
|
||||
|
||||
```php
|
||||
use Filament\Support\Enums\ActionSize;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;use Filament\Support\Enums\ActionSize;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
@@ -403,7 +392,7 @@ ActionGroup::make([
|
||||
You may set the tooltip of the action group using the `tooltip()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
|
||||
ActionGroup::make([
|
||||
// ...
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
$actions = array_reduce(
|
||||
$actions,
|
||||
function (array $carry, $action) use ($record): array {
|
||||
if (! $action instanceof \Filament\Tables\Actions\ActionGroup) {
|
||||
if (! $action instanceof \Filament\Actions\ActionGroup) {
|
||||
$action = clone $action;
|
||||
}
|
||||
|
||||
if (! $action instanceof \Filament\Tables\Actions\BulkAction) {
|
||||
if (! $action instanceof \Filament\Actions\BulkAction) {
|
||||
$action->record($record);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@
|
||||
$header = $getHeader();
|
||||
$headerActions = array_filter(
|
||||
$getHeaderActions(),
|
||||
fn (\Filament\Actions\Action | \Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(),
|
||||
fn (\Filament\Actions\Action | \Filament\Actions\BulkAction | \Filament\Actions\ActionGroup $action): bool => $action->isVisible(),
|
||||
);
|
||||
$headerActionsPosition = $getHeaderActionsPosition();
|
||||
$heading = $getHeading();
|
||||
$group = $getGrouping();
|
||||
$bulkActions = array_filter(
|
||||
$getBulkActions(),
|
||||
fn (\Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(),
|
||||
fn (\Filament\Actions\BulkAction | \Filament\Actions\ActionGroup $action): bool => $action->isVisible(),
|
||||
);
|
||||
$groups = $getGroups();
|
||||
$description = $getDescription();
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup as BaseActionGroup;
|
||||
|
||||
/**
|
||||
* @property array<Action | BulkAction> $actions
|
||||
*/
|
||||
class ActionGroup extends BaseActionGroup
|
||||
{
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions\Contracts;
|
||||
|
||||
use Filament\Tables\Table;
|
||||
|
||||
interface HasTable
|
||||
{
|
||||
public function table(Table $table): static;
|
||||
|
||||
public function getTable(): Table;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CreateAction extends Action
|
||||
{
|
||||
use CanCustomizeProcess;
|
||||
|
||||
protected bool | Closure $canCreateAnother = true;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'create';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(fn (): string => __('filament-actions::create.single.label', ['label' => $this->getModelLabel()]));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::create.single.modal.heading', ['label' => $this->getModelLabel()]));
|
||||
|
||||
$this->modalSubmitActionLabel(__('filament-actions::create.single.modal.actions.create.label'));
|
||||
|
||||
$this->extraModalFooterActions(function (): array {
|
||||
return $this->canCreateAnother() ? [
|
||||
$this->makeModalSubmitAction('createAnother', ['another' => true])
|
||||
->label(__('filament-actions::create.single.modal.actions.create_another.label')),
|
||||
] : [];
|
||||
});
|
||||
|
||||
$this->successNotificationTitle(__('filament-actions::create.single.notifications.created.title'));
|
||||
|
||||
$this->action(function (array $arguments, ComponentContainer $form, HasTable $livewire): void {
|
||||
$model = $this->getModel();
|
||||
|
||||
$record = $this->process(function (array $data, Table $table) use ($model): Model {
|
||||
$relationship = $table->getRelationship();
|
||||
|
||||
$pivotData = [];
|
||||
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$pivotColumns = $relationship->getPivotColumns();
|
||||
|
||||
$pivotData = Arr::only($data, $pivotColumns);
|
||||
$data = Arr::except($data, $pivotColumns);
|
||||
}
|
||||
|
||||
if ($translatableContentDriver = $table->makeTranslatableContentDriver()) {
|
||||
$record = $translatableContentDriver->makeRecord($model, $data);
|
||||
} else {
|
||||
$record = new $model();
|
||||
$record->fill($data);
|
||||
}
|
||||
|
||||
if (
|
||||
(! $relationship) ||
|
||||
$relationship instanceof HasManyThrough
|
||||
) {
|
||||
$record->save();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$relationship->save($record, $pivotData);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
$relationship->save($record);
|
||||
|
||||
return $record;
|
||||
});
|
||||
|
||||
$this->record($record);
|
||||
$form->model($record)->saveRelationships();
|
||||
|
||||
if ($arguments['another'] ?? false) {
|
||||
$this->callAfter();
|
||||
$this->sendSuccessNotification();
|
||||
|
||||
$this->record(null);
|
||||
|
||||
// Ensure that the form record is anonymized so that relationships aren't loaded.
|
||||
$form->model($model);
|
||||
|
||||
$form->fill();
|
||||
|
||||
$this->halt();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->success();
|
||||
});
|
||||
}
|
||||
|
||||
public function createAnother(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->canCreateAnother = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `createAnother()` instead.
|
||||
*/
|
||||
public function disableCreateAnother(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->createAnother(fn (CreateAction $action): bool => ! $action->evaluate($condition));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canCreateAnother(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->canCreateAnother);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeleteAction extends Action
|
||||
{
|
||||
use CanCustomizeProcess;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'delete';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(__('filament-actions::delete.single.label'));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::delete.single.modal.heading', ['label' => $this->getRecordTitle()]));
|
||||
|
||||
$this->modalSubmitActionLabel(__('filament-actions::delete.single.modal.actions.delete.label'));
|
||||
|
||||
$this->successNotificationTitle(__('filament-actions::delete.single.notifications.deleted.title'));
|
||||
|
||||
$this->color('danger');
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::delete-action') ?? 'heroicon-m-trash');
|
||||
|
||||
$this->requiresConfirmation();
|
||||
|
||||
$this->modalIcon(FilamentIcon::resolve('actions::delete-action.modal') ?? 'heroicon-o-trash');
|
||||
|
||||
$this->hidden(static function (Model $record): bool {
|
||||
if (! method_exists($record, 'trashed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $record->trashed();
|
||||
});
|
||||
|
||||
$this->action(function (): void {
|
||||
$result = $this->process(static fn (Model $record) => $record->delete());
|
||||
|
||||
if (! $result) {
|
||||
$this->failure();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->success();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class EditAction extends Action
|
||||
{
|
||||
use CanCustomizeProcess;
|
||||
|
||||
protected ?Closure $mutateRecordDataUsing = null;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'edit';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(__('filament-actions::edit.single.label'));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::edit.single.modal.heading', ['label' => $this->getRecordTitle()]));
|
||||
|
||||
$this->modalSubmitActionLabel(__('filament-actions::edit.single.modal.actions.save.label'));
|
||||
|
||||
$this->successNotificationTitle(__('filament-actions::edit.single.notifications.saved.title'));
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::edit-action') ?? 'heroicon-m-pencil-square');
|
||||
|
||||
$this->fillForm(function (Model $record, Table $table): array {
|
||||
if ($translatableContentDriver = $table->makeTranslatableContentDriver()) {
|
||||
$data = $translatableContentDriver->getRecordAttributesToArray($record);
|
||||
} else {
|
||||
$data = $record->attributesToArray();
|
||||
}
|
||||
|
||||
if ($this->mutateRecordDataUsing) {
|
||||
$data = $this->evaluate($this->mutateRecordDataUsing, ['data' => $data]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
$this->action(function (): void {
|
||||
$this->process(function (array $data, Model $record, Table $table) {
|
||||
$relationship = $table->getRelationship();
|
||||
|
||||
$translatableContentDriver = $table->makeTranslatableContentDriver();
|
||||
|
||||
if ($relationship instanceof BelongsToMany) {
|
||||
$pivot = $record->{$relationship->getPivotAccessor()};
|
||||
|
||||
$pivotColumns = $relationship->getPivotColumns();
|
||||
$pivotData = Arr::only($data, $pivotColumns);
|
||||
|
||||
if (count($pivotColumns)) {
|
||||
if ($translatableContentDriver) {
|
||||
$translatableContentDriver->updateRecord($pivot, $pivotData);
|
||||
} else {
|
||||
$pivot->update($pivotData);
|
||||
}
|
||||
}
|
||||
|
||||
$data = Arr::except($data, $pivotColumns);
|
||||
}
|
||||
|
||||
if ($translatableContentDriver) {
|
||||
$translatableContentDriver->updateRecord($record, $data);
|
||||
} else {
|
||||
$record->update($data);
|
||||
}
|
||||
});
|
||||
|
||||
$this->success();
|
||||
});
|
||||
}
|
||||
|
||||
public function mutateRecordDataUsing(?Closure $callback): static
|
||||
{
|
||||
$this->mutateRecordDataUsing = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanExportRecords;
|
||||
|
||||
class ExportAction extends Action
|
||||
{
|
||||
use CanExportRecords;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ForceDeleteAction extends Action
|
||||
{
|
||||
use CanCustomizeProcess;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'forceDelete';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(__('filament-actions::force-delete.single.label'));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::force-delete.single.modal.heading', ['label' => $this->getRecordTitle()]));
|
||||
|
||||
$this->modalSubmitActionLabel(__('filament-actions::force-delete.single.modal.actions.delete.label'));
|
||||
|
||||
$this->successNotificationTitle(__('filament-actions::force-delete.single.notifications.deleted.title'));
|
||||
|
||||
$this->color('danger');
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::force-delete-action') ?? 'heroicon-m-trash');
|
||||
|
||||
$this->requiresConfirmation();
|
||||
|
||||
$this->modalIcon(FilamentIcon::resolve('actions::force-delete-action.modal') ?? 'heroicon-o-trash');
|
||||
|
||||
$this->action(function (): void {
|
||||
$result = $this->process(static fn (Model $record) => $record->forceDelete());
|
||||
|
||||
if (! $result) {
|
||||
$this->failure();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->success();
|
||||
});
|
||||
|
||||
$this->visible(static function (Model $record): bool {
|
||||
if (! method_exists($record, 'trashed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $record->trashed();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanImportRecords;
|
||||
|
||||
class ImportAction extends Action
|
||||
{
|
||||
use CanImportRecords;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanReplicateRecords;
|
||||
use Filament\Actions\Contracts\ReplicatesRecords;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
|
||||
class ReplicateAction extends Action implements ReplicatesRecords
|
||||
{
|
||||
use CanReplicateRecords {
|
||||
setUp as baseSetUp;
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->baseSetUp();
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::replicate-action') ?? 'heroicon-m-square-2-stack');
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\CanCustomizeProcess;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RestoreAction extends Action
|
||||
{
|
||||
use CanCustomizeProcess;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'restore';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(__('filament-actions::restore.single.label'));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::restore.single.modal.heading', ['label' => $this->getRecordTitle()]));
|
||||
|
||||
$this->modalSubmitActionLabel(__('filament-actions::restore.single.modal.actions.restore.label'));
|
||||
|
||||
$this->successNotificationTitle(__('filament-actions::restore.single.notifications.restored.title'));
|
||||
|
||||
$this->color('gray');
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::restore-action') ?? 'heroicon-m-arrow-uturn-left');
|
||||
|
||||
$this->requiresConfirmation();
|
||||
|
||||
$this->modalIcon(FilamentIcon::resolve('actions::restore-action.modal') ?? 'heroicon-o-arrow-uturn-left');
|
||||
|
||||
$this->action(function (Model $record): void {
|
||||
if (! method_exists($record, 'restore')) {
|
||||
$this->failure();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $this->process(static fn () => $record->restore());
|
||||
|
||||
if (! $result) {
|
||||
$this->failure();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->success();
|
||||
});
|
||||
|
||||
$this->visible(static function (Model $record): bool {
|
||||
if (! method_exists($record, 'trashed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $record->trashed();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns;
|
||||
|
||||
class SelectAction extends Action
|
||||
{
|
||||
use Concerns\HasSelect;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->view('filament-actions::select-action');
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tables\Actions;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\StaticAction;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ViewAction extends Action
|
||||
{
|
||||
protected ?Closure $mutateRecordDataUsing = null;
|
||||
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'view';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label(__('filament-actions::view.single.label'));
|
||||
|
||||
$this->modalHeading(fn (): string => __('filament-actions::view.single.modal.heading', ['label' => $this->getRecordTitle()]));
|
||||
|
||||
$this->modalSubmitAction(false);
|
||||
$this->modalCancelAction(fn (StaticAction $action) => $action->label(__('filament-actions::view.single.modal.actions.close.label')));
|
||||
|
||||
$this->color('gray');
|
||||
|
||||
$this->icon(FilamentIcon::resolve('actions::view-action') ?? 'heroicon-m-eye');
|
||||
|
||||
$this->disabledSchema();
|
||||
|
||||
$this->fillForm(function (Model $record, Table $table): array {
|
||||
if ($translatableContentDriver = $table->makeTranslatableContentDriver()) {
|
||||
$data = $translatableContentDriver->getRecordAttributesToArray($record);
|
||||
} else {
|
||||
$data = $record->attributesToArray();
|
||||
}
|
||||
|
||||
if ($this->mutateRecordDataUsing) {
|
||||
$data = $this->evaluate($this->mutateRecordDataUsing, ['data' => $data]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
$this->action(static function (): void {
|
||||
});
|
||||
}
|
||||
|
||||
public function mutateRecordDataUsing(?Closure $callback): static
|
||||
{
|
||||
$this->mutateRecordDataUsing = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Filament\Tables\Concerns;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
trait HasActions
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Filament\Tables\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Schema\ComponentContainer;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Filament\Tables\Concerns;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Filament\Tables\Concerns;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Filament\Tables\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Tables\Table\Concerns;
|
||||
|
||||
use Filament\Support\Contracts\TranslatableContentDriver;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
|
||||
trait BelongsToLivewire
|
||||
@@ -20,9 +19,4 @@ trait BelongsToLivewire
|
||||
{
|
||||
return $this->livewire;
|
||||
}
|
||||
|
||||
public function makeTranslatableContentDriver(): ?TranslatableContentDriver
|
||||
{
|
||||
return $this->getLivewire()->makeFilamentTranslatableContentDriver();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Filament\Tables\Table\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Support\Enums\ActionSize;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Enums\ActionsPosition;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Filament\Tables\Table\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Enums\RecordCheckboxPosition;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Filament\Tables\Table\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Filament\Tables\Table\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Actions\ActionGroup;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Tables\Actions\HeaderActionsPosition;
|
||||
use Illuminate\Support\Arr;
|
||||
use InvalidArgumentException;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Filament\Tables\Testing;
|
||||
|
||||
use Closure;
|
||||
use Filament\Tables\Actions\BulkAction;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -55,12 +55,12 @@ class PostResource extends Resource
|
||||
->query(fn (Builder $query) => $query->where('is_published', true)),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
\Filament\Actions\ViewAction::make(),
|
||||
\Filament\Actions\EditAction::make(),
|
||||
\Filament\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ class UserResource extends Resource
|
||||
->label('Posts Rating Sum'),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
\Filament\Actions\ViewAction::make(),
|
||||
\Filament\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Tests\Models\Post;
|
||||
use Filament\Tests\Panels\Fixtures\Resources\PostResource;
|
||||
use Filament\Tests\Panels\Fixtures\Resources\PostResource\Pages\ListPosts;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\Testing\Fixtures\TestAction;
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tests\Models\Post;
|
||||
use Filament\Tests\Tables\Fixtures\PostsTable;
|
||||
use Filament\Tests\Tables\TestCase;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\Testing\Fixtures\TestAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tests\Models\Post;
|
||||
use Filament\Tests\Tables\Fixtures\PostsTable;
|
||||
use Filament\Tests\Tables\TestCase;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tests\Models\Post;
|
||||
use Filament\Tests\Tables\Fixtures\PostsTable;
|
||||
|
||||
@@ -147,15 +147,15 @@ class PostsTable extends Component implements HasActions, HasForms, Tables\Contr
|
||||
->url('https://filamentphp.com', true),
|
||||
Action::make('urlNotInNewTab')
|
||||
->url('https://filamentphp.com'),
|
||||
Tables\Actions\AttachAction::make(),
|
||||
Tables\Actions\AttachAction::make('attachMultiple')
|
||||
\Filament\Actions\AttachAction::make(),
|
||||
\Filament\Actions\AttachAction::make('attachMultiple')
|
||||
->multiple(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\ForceDeleteAction::make(),
|
||||
Tables\Actions\RestoreAction::make(),
|
||||
\Filament\Actions\EditAction::make(),
|
||||
\Filament\Actions\DeleteAction::make(),
|
||||
\Filament\Actions\ForceDeleteAction::make(),
|
||||
\Filament\Actions\RestoreAction::make(),
|
||||
Action::make('parent')
|
||||
->schema([
|
||||
TextInput::make('foo')
|
||||
@@ -195,10 +195,10 @@ class PostsTable extends Component implements HasActions, HasForms, Tables\Contr
|
||||
])
|
||||
->action(fn (array $data, Post $record) => $this->dispatch('nested-called', bar: $data['bar'], recordKey: $record->getKey())),
|
||||
]),
|
||||
Tables\Actions\ActionGroup::make([
|
||||
Tables\Actions\DeleteAction::make('groupedDelete'),
|
||||
Tables\Actions\ForceDeleteAction::make('groupedForceDelete'),
|
||||
Tables\Actions\RestoreAction::make('groupedRestore'),
|
||||
\Filament\Actions\ActionGroup::make([
|
||||
\Filament\Actions\DeleteAction::make('groupedDelete'),
|
||||
\Filament\Actions\ForceDeleteAction::make('groupedForceDelete'),
|
||||
\Filament\Actions\RestoreAction::make('groupedRestore'),
|
||||
Action::make('groupedParent')
|
||||
->schema([
|
||||
TextInput::make('foo')
|
||||
@@ -241,8 +241,8 @@ class PostsTable extends Component implements HasActions, HasForms, Tables\Contr
|
||||
]),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\BulkAction::make('data')
|
||||
\Filament\Actions\DeleteBulkAction::make(),
|
||||
\Filament\Actions\BulkAction::make('data')
|
||||
->mountUsing(fn (ComponentContainer $form) => $form->fill(['foo' => 'bar']))
|
||||
->form([
|
||||
TextInput::make('payload')->required(),
|
||||
@@ -250,32 +250,32 @@ class PostsTable extends Component implements HasActions, HasForms, Tables\Contr
|
||||
->action(function (array $data) {
|
||||
$this->dispatch('data-called', data: $data);
|
||||
}),
|
||||
Tables\Actions\BulkAction::make('arguments')
|
||||
\Filament\Actions\BulkAction::make('arguments')
|
||||
->requiresConfirmation()
|
||||
->action(function (array $arguments) {
|
||||
$this->dispatch('arguments-called', arguments: $arguments);
|
||||
}),
|
||||
Tables\Actions\BulkAction::make('halt')
|
||||
\Filament\Actions\BulkAction::make('halt')
|
||||
->requiresConfirmation()
|
||||
->action(function (Tables\Actions\BulkAction $action) {
|
||||
->action(function (\Filament\Actions\BulkAction $action) {
|
||||
$this->dispatch('halt-called');
|
||||
|
||||
$action->halt();
|
||||
}),
|
||||
Tables\Actions\BulkAction::make('visible'),
|
||||
Tables\Actions\BulkAction::make('hidden')
|
||||
\Filament\Actions\BulkAction::make('visible'),
|
||||
\Filament\Actions\BulkAction::make('hidden')
|
||||
->hidden(),
|
||||
Tables\Actions\BulkAction::make('enabled'),
|
||||
Tables\Actions\BulkAction::make('disabled')
|
||||
\Filament\Actions\BulkAction::make('enabled'),
|
||||
\Filament\Actions\BulkAction::make('disabled')
|
||||
->disabled(),
|
||||
Tables\Actions\BulkAction::make('hasIcon')
|
||||
\Filament\Actions\BulkAction::make('hasIcon')
|
||||
->icon('heroicon-m-pencil-square'),
|
||||
Tables\Actions\BulkAction::make('hasLabel')
|
||||
\Filament\Actions\BulkAction::make('hasLabel')
|
||||
->label('My Action'),
|
||||
Tables\Actions\BulkAction::make('hasColor')
|
||||
\Filament\Actions\BulkAction::make('hasColor')
|
||||
->color('primary'),
|
||||
Tables\Actions\BulkAction::make('exists'),
|
||||
Tables\Actions\BulkAction::make('existsInOrder'),
|
||||
\Filament\Actions\BulkAction::make('exists'),
|
||||
\Filament\Actions\BulkAction::make('existsInOrder'),
|
||||
])
|
||||
->emptyStateActions([
|
||||
Action::make('emptyExists'),
|
||||
|
||||
Reference in New Issue
Block a user