Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Jul 26, 2023
1 parent a105280 commit 413c1ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/panels/docs/14-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ vendor/bin/filament-v3

Make sure to carefully follow the instructions, and review the changes made by the script. You may need to make some manual changes to your code afterwards, but the script should handle most of the repetitive work for you.

A new `app/Providers/Filament/*PanelProvider.php` file will be created, and the configuration from your old `config/filament.php` file should be copied. Since this is a [Laravel service provider](https://laravel.com/docs/providers), it needs to be registered in `config/app.php`. Filament will attempt to do this for you, but if you get an error while trying to access your panel then this process has probably failed. You can manually register the service provider by adding it to the `providers` array.

Finally, you must run `php artisan filament:install` to finalize the Filament v3 installation. This command must be run for all new Filament projects.

You can now `composer remove filament/upgrade` as you don't need it any more.
Expand All @@ -40,7 +42,7 @@ Before you can create the new panel provider, make sure that you've got Filament
php artisan filament:install --panels
```

A new `app/Providers/Filament/AdminPanelProvider.php` file will be created, ready for you to transfer over your old configuration from the `config/filament.php` file.
A new `app/Providers/Filament/AdminPanelProvider.php` file will be created, ready for you to transfer over your old configuration from the `config/filament.php` file. Since this is a [Laravel service provider](https://laravel.com/docs/providers), it needs to be registered in `config/app.php`. Filament will attempt to do this for you, but if you get an error while trying to access your panel then this process has probably failed. You can manually register the service provider by adding it to the `providers` array.

Most configuration transfer is very self-explanatory, but if you get stuck please refer to the [configuration documentation](configuration).

Expand Down
14 changes: 7 additions & 7 deletions packages/tables/resources/views/components/actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
@php
$actions = array_filter(
$actions,
fn ($action): bool => $action->isVisible(),
function (\Filament\Tables\Actions\Action | \Filament\Tables\Actions\BulkAction $action) use ($record): bool {
if (! $action instanceof \Filament\Tables\Actions\BulkAction) {
$action->record($record);
}
return $action->isVisible();
},
);
@endphp

Expand All @@ -28,12 +34,6 @@
}}
>
@foreach ($actions as $action)
@php
if (! $action instanceof \Filament\Tables\Actions\BulkAction) {
$action->record($record);
}
@endphp

{{ $action }}
@endforeach
</div>
10 changes: 7 additions & 3 deletions packages/upgrade/bin/create-filament-v3-panel-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@

$pathPhp = preg_match('/\'path\'\s*=>\s*(.*),/', $config, $matches) ? $matches[1] : '\'admin\'';
$path = preg_match('/env\(\'FILAMENT_PATH\',\s*\'(.*)\'\)/', $pathPhp, $matches) ? $matches[1] : 'admin';
$pathPhp = $path ? "\n ->path('{$path}')" : '';

$isAdmin = trim($path, '/') === 'admin';
$className = $isAdmin ? 'AdminPanelProvider' : 'AppPanelProvider';
$id = $isAdmin ? 'admin' : 'app';

$domainPhp = preg_match('/\'domain\'\s*=>\s*(.*),/', $config, $matches) ? $matches[1] : null;
$domainPhp = $domainPhp ? "\n ->domain({$domainPhp})" : '';
if ($domainPhp === 'env(\'FILAMENT_DOMAIN\')') {
$domainPhp = null;
}
$domain = preg_match('/env\(\'FILAMENT_DOMAIN\',\s*\'(.*)\'\)/', $pathPhp, $matches) ? $matches[1] : '';
$domainPhp = $domain ? "\n ->domain('{$domain}')" : '';

$authGuardPhp = preg_match('/\'guard\'\s*=>\s*(.*),/', $config, $matches) ? $matches[1] : null;
if ($authGuardPhp === 'env(\'FILAMENT_AUTH_GUARD\', \'web\')') {
Expand Down Expand Up @@ -74,8 +79,7 @@ public function panel(Panel \$panel): Panel
{
return \$panel
->default()
->id('{$id}')
->path({$pathPhp}){$domainPhp}
->id('{$id}'){$pathPhp}{$domainPhp}
->login(){$authGuardPhp}
->colors([
'primary' => Color::Amber,
Expand Down

0 comments on commit 413c1ab

Please sign in to comment.