Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed May 7, 2024
1 parent 719569c commit 19c142c
Show file tree
Hide file tree
Showing 54 changed files with 308 additions and 517 deletions.
2 changes: 0 additions & 2 deletions docs-assets/app/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ export default defineConfig({
refresh: [
...refreshPaths,
'app/Filament/**',
'app/Forms/Components/**',
'app/Livewire/**',
'app/Providers/Filament/**',
'app/Tables/Columns/**',
],
}),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/docs/07-prebuilt-actions/08-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Import action

## Overview

Filament v3.1 introduced a prebuilt action that is able to import rows from a CSV. When the trigger button is clicked, a modal asks the user for a file. Once they upload one, they are able to map each column in the CSV to a real column in the database. If any rows fail validation, they will be compiled into a downloadable CSV for the user to review after the rest of the rows have been imported. Users can also download an example CSV file containing all the columns that can be imported.
Filament includes a prebuilt action that is able to import rows from a CSV. When the trigger button is clicked, a modal asks the user for a file. Once they upload one, they are able to map each column in the CSV to a real column in the database. If any rows fail validation, they will be compiled into a downloadable CSV for the user to review after the rest of the rows have been imported. Users can also download an example CSV file containing all the columns that can be imported.

This feature uses [job batches](https://laravel.com/docs/queues#job-batching) and [database notifications](../../notifications/database-notifications#overview), so you need to publish those migrations from Laravel. Also, you need to publish the migrations for tables that Filament uses to store information about imports:

Expand Down
2 changes: 1 addition & 1 deletion packages/actions/docs/07-prebuilt-actions/09-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Export action

## Overview

Filament v3.2 introduced a prebuilt action that is able to export rows to a CSV or XLSX file. When the trigger button is clicked, a modal asks for the columns that they want to export, and what they should be labeled. This feature uses [job batches](https://laravel.com/docs/queues#job-batching) and [database notifications](../../notifications/database-notifications#overview), so you need to publish those migrations from Laravel. Also, you need to publish the migrations for tables that Filament uses to store information about exports:
Filament includes a prebuilt action that is able to export rows to a CSV or XLSX file. When the trigger button is clicked, a modal asks for the columns that they want to export, and what they should be labeled. This feature uses [job batches](https://laravel.com/docs/queues#job-batching) and [database notifications](../../notifications/database-notifications#overview), so you need to publish those migrations from Laravel. Also, you need to publish the migrations for tables that Filament uses to store information about exports:

```bash
# Laravel 11 and higher
Expand Down
3 changes: 0 additions & 3 deletions packages/actions/resources/views/components/actions.blade.php

This file was deleted.

35 changes: 6 additions & 29 deletions packages/actions/src/ActionsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Filament\Actions;

use Filament\Actions\Commands\MakeExporterCommand;
use Filament\Actions\Commands\MakeImporterCommand;
use Filament\Actions\Testing\TestsActions;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Routing\Router;
Expand All @@ -15,7 +17,10 @@ public function configurePackage(Package $package): void
{
$package
->name('filament-actions')
->hasCommands($this->getCommands())
->hasCommands([
Commands\MakeExporterCommand::class,
Commands\MakeImporterCommand::class,
])
->hasMigrations([
'create_imports_table',
'create_exports_table',
Expand Down Expand Up @@ -43,32 +48,4 @@ public function packageBooted(): void

Testable::mixin(new TestsActions());
}

/**
* @return array<class-string>
*/
protected function getCommands(): array
{
$commands = [
Commands\MakeExporterCommand::class,
Commands\MakeImporterCommand::class,
];

$aliases = [];

foreach ($commands as $command) {
$class = 'Filament\\Actions\\Commands\\Aliases\\' . class_basename($command);

if (! class_exists($class)) {
continue;
}

$aliases[] = $class;
}

return [
...$commands,
...$aliases,
];
}
}
14 changes: 0 additions & 14 deletions packages/actions/src/Commands/Aliases/MakeExporterCommand.php

This file was deleted.

14 changes: 0 additions & 14 deletions packages/actions/src/Commands/Aliases/MakeImporterCommand.php

This file was deleted.

11 changes: 10 additions & 1 deletion packages/actions/src/Commands/MakeExporterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use function Filament\Support\get_model_label;
use function Laravel\Prompts\text;

#[AsCommand(name: 'make:filament-exporter')]
#[AsCommand(name: 'make:filament-exporter', aliases: [
'filament:exporter',
])]
class MakeExporterCommand extends Command
{
use CanIndentStrings;
Expand All @@ -23,6 +25,13 @@ class MakeExporterCommand extends Command

protected $signature = 'make:filament-exporter {name?} {--G|generate} {--F|force}';

/**
* @var array<string>
*/
protected $aliases = [
'filament:exporter',
];

public function handle(): int
{
$model = (string) str($this->argument('name') ?? text(
Expand Down
11 changes: 10 additions & 1 deletion packages/actions/src/Commands/MakeImporterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use function Filament\Support\get_model_label;
use function Laravel\Prompts\text;

#[AsCommand(name: 'make:filament-importer')]
#[AsCommand(name: 'make:filament-importer', aliases: [
'filament:exporter',
])]
class MakeImporterCommand extends Command
{
use CanIndentStrings;
Expand All @@ -23,6 +25,13 @@ class MakeImporterCommand extends Command

protected $signature = 'make:filament-importer {name?} {--G|generate} {--F|force}';

/**
* @var array<string>
*/
protected $aliases = [
'filament:exporter',
];

public function handle(): int
{
$model = (string) str($this->argument('name') ?? text(
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/docs/03-fields/20-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ You may create your own custom field classes and views, which you can reuse acro
To create a custom field class and view, you may use the following command:

```bash
php artisan make:form-field RangeSlider
php artisan make:filament-form-field RangeSlider
```

This will create the following field class:
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/docs/04-layout/08-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You may create your own custom component classes and views, which you can reuse
To create a custom column class and view, you may use the following command:

```bash
php artisan make:form-layout Wizard
php artisan make:filament-schema-layout Wizard
```

This will create the following layout component class:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function createComment(): void
It's advised that you learn how to set up a Livewire component with the Form Builder manually, but once you are confident, you can use the CLI to generate a form for you.

```bash
php artisan make:livewire-form RegistrationForm
php artisan make:filament-livewire-form RegistrationForm
```

This will generate a new `app/Livewire/RegistrationForm.php` component, which you can customize.
Expand All @@ -298,21 +298,21 @@ Filament is also able to generate forms for a specific Eloquent model. These are
When generating a form with the `make:livewire-form` command, it will ask for the name of the model:

```bash
php artisan make:livewire-form Products/CreateProduct
php artisan make:filament-livewire-form Products/CreateProduct
```

#### Generating an edit form for an Eloquent record

By default, passing a model to the `make:livewire-form` command will result in a form that creates a new record in your database. If you pass the `--edit` flag to the command, it will generate an edit form for a specific record. This will automatically fill the form with the data from the record, and save the data back to the model when the form is submitted.

```bash
php artisan make:livewire-form Products/EditProduct --edit
php artisan make:filament-livewire-form Products/EditProduct --edit
```

### Automatically generating form schemas

Filament is also able to guess which form fields you want in the schema, based on the model's database columns. You can use the `--generate` flag when generating your form:

```bash
php artisan make:livewire-form Products/CreateProduct --generate
php artisan make:filament-livewire-form Products/CreateProduct --generate
```
14 changes: 0 additions & 14 deletions packages/forms/src/Commands/Aliases/MakeFieldCommand.php

This file was deleted.

29 changes: 24 additions & 5 deletions packages/forms/src/Commands/MakeFieldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,33 @@

use function Laravel\Prompts\text;

#[AsCommand(name: 'make:form-field')]
#[AsCommand(name: 'make:filament-form-field', aliases: [
'filament:field',
'filament:form-field',
'forms:field',
'forms:make-field',
'make:filament-field',
'make:form-field',
])]
class MakeFieldCommand extends Command
{
use CanManipulateFiles;

protected $description = 'Create a new form field class and view';

protected $signature = 'make:form-field {name?} {--F|force}';
protected $signature = 'make:filament-form-field {name?} {--F|force}';

/**
* @var array<string>
*/
protected $aliases = [
'filament:field',
'filament:form-field',
'forms:field',
'forms:make-field',
'make:filament-field',
'make:form-field',
];

public function handle(): int
{
Expand All @@ -35,14 +54,14 @@ public function handle(): int
'';

$view = str($field)
->prepend('forms\\components\\')
->prepend('filament\\forms\\components\\')
->explode('\\')
->map(static fn ($segment) => Str::kebab($segment))
->implode('.');

$path = app_path(
(string) str($field)
->prepend('Forms\\Components\\')
->prepend('Filament\\Forms\\Components\\')
->replace('\\', '/')
->append('.php'),
);
Expand All @@ -61,7 +80,7 @@ public function handle(): int

$this->copyStubToApp('Field', $path, [
'class' => $fieldClass,
'namespace' => 'App\\Forms\\Components' . ($fieldNamespace !== '' ? "\\{$fieldNamespace}" : ''),
'namespace' => 'App\\Filament\\Forms\\Components' . ($fieldNamespace !== '' ? "\\{$fieldNamespace}" : ''),
'view' => $view,
]);

Expand Down
13 changes: 11 additions & 2 deletions packages/forms/src/Commands/MakeFormCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;

#[AsCommand(name: 'make:livewire-form')]
#[AsCommand(name: 'make:filament-livewire-form', aliases: [
'make:livewire-form',
])]
class MakeFormCommand extends Command
{
use CanGenerateForms;
Expand All @@ -23,7 +25,14 @@ class MakeFormCommand extends Command

protected $description = 'Create a new Livewire component containing a Filament form';

protected $signature = 'make:livewire-form {name?} {model?} {--E|edit} {--G|generate} {--F|force}';
protected $signature = 'make:filament-livewire-form {name?} {model?} {--E|edit} {--G|generate} {--F|force}';

/**
* @var array<string>
*/
protected $aliases = [
'make:livewire-form',
];

public function handle(): int
{
Expand Down
33 changes: 4 additions & 29 deletions packages/forms/src/FormsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public function configurePackage(Package $package): void
{
$package
->name('filament-forms')
->hasCommands($this->getCommands())
->hasCommands([
Commands\MakeFieldCommand::class,
Commands\MakeFormCommand::class,
])
->hasTranslations()
->hasViews();
}
Expand Down Expand Up @@ -49,32 +52,4 @@ public function packageBooted(): void
Testable::mixin(new TestsForms());
Testable::mixin(new TestsFormComponentActions());
}

/**
* @return array<class-string>
*/
protected function getCommands(): array
{
$commands = [
Commands\MakeFieldCommand::class,
Commands\MakeFormCommand::class,
];

$aliases = [];

foreach ($commands as $command) {
$class = 'Filament\\Forms\\Commands\\Aliases\\' . class_basename($command);

if (! class_exists($class)) {
continue;
}

$aliases[] = $class;
}

return [
...$commands,
...$aliases,
];
}
}
2 changes: 1 addition & 1 deletion packages/infolists/docs/03-entries/08-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You may create your own custom entry classes and entry views, which you can reus
To create a custom entry class and view, you may use the following command:

```bash
php artisan make:infolist-entry StatusSwitcher
php artisan make:filament-infolist-entry StatusSwitcher
```

This will create the following entry class:
Expand Down
2 changes: 1 addition & 1 deletion packages/infolists/docs/04-layout/07-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You may create your own custom component classes and views, which you can reuse
To create a custom column class and view, you may use the following command:

```bash
php artisan make:infolist-layout Box
php artisan make:filament-schema-layout Box
```

This will create the following layout component class:
Expand Down
Loading

0 comments on commit 19c142c

Please sign in to comment.