mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Remove FilamentManager::namespaceFor in favor of simple concatenation
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
@@ -33,12 +32,12 @@ class AdminPanelProvider extends PanelProvider
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: Filament::namespaceFor('Filament\\Resources'))
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: Filament::namespaceFor('Filament\\Pages'))
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: app()->getNamespace() . 'Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: app()->getNamespace() . 'Filament\\Pages')
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: Filament::namespaceFor('Filament\\Widgets'))
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: app()->getNamespace() . 'Filament\\Widgets')
|
||||
->widgets([
|
||||
Widgets\AccountWidget::class,
|
||||
Widgets\FilamentInfoWidget::class,
|
||||
|
||||
@@ -23,9 +23,9 @@ public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
// ...
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: Filament::namespaceFor('Filament\\Resources'))
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: Filament::namespaceFor('Filament\\Pages'))
|
||||
->discoverClusters(in: app_path('Filament/Clusters'), for: Filament::namespaceFor('Filament\\Clusters'));
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Actions\Commands;
|
||||
|
||||
use Filament\Actions\Commands\FileGenerators\ExporterClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
@@ -85,7 +84,7 @@ class MakeExporterCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -132,7 +131,7 @@ class MakeExporterCommand extends Command
|
||||
$this->modelFqnEnd = 'Resource';
|
||||
}
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
} else {
|
||||
@@ -152,7 +151,7 @@ class MakeExporterCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Actions\Commands;
|
||||
|
||||
use Filament\Actions\Commands\FileGenerators\ImporterClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
@@ -91,7 +90,7 @@ class MakeImporterCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -139,7 +138,7 @@ class MakeImporterCommand extends Command
|
||||
$this->modelFqnEnd = 'Resource';
|
||||
}
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
} else {
|
||||
@@ -159,7 +158,7 @@ class MakeImporterCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\Exports\Enums\Contracts\ExportFormat as ExportFormatInterface;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -78,7 +77,7 @@ abstract class Exporter
|
||||
{
|
||||
return static::$model ?? (string) str(class_basename(static::class))
|
||||
->beforeLast('Exporter')
|
||||
->prepend(Filament::namespaceFor('Models\\'));
|
||||
->prepend(app()->getNamespace() . 'Models\\');
|
||||
}
|
||||
|
||||
abstract public static function getCompletedNotificationBody(Export $export): string;
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace Filament\Actions\Exports\Models;
|
||||
use Carbon\CarbonInterface;
|
||||
use Exception;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -58,7 +57,7 @@ class Export extends Model
|
||||
return $this->belongsTo($authenticatable::class);
|
||||
}
|
||||
|
||||
$userClass = Filament::namespaceFor('Models\\User');
|
||||
$userClass = app()->getNamespace() . 'Models\\User';
|
||||
|
||||
if (! class_exists($userClass)) {
|
||||
throw new Exception('No [' . $userClass . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
|
||||
|
||||
@@ -6,7 +6,6 @@ use Carbon\CarbonInterface;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
@@ -294,7 +293,7 @@ abstract class Importer
|
||||
{
|
||||
return static::$model ?? (string) str(class_basename(static::class))
|
||||
->beforeLast('Importer')
|
||||
->prepend(Filament::namespaceFor('Models\\'));
|
||||
->prepend(app()->getNamespace() . 'Models\\');
|
||||
}
|
||||
|
||||
abstract public static function getCompletedNotificationBody(Import $import): string;
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace Filament\Actions\Imports\Models;
|
||||
use Carbon\CarbonInterface;
|
||||
use Exception;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -64,7 +63,7 @@ class Import extends Model
|
||||
return $this->belongsTo($authenticatable::class);
|
||||
}
|
||||
|
||||
$userClass = Filament::namespaceFor('Models\\User');
|
||||
$userClass = app()->getNamespace() . 'Models\\User';
|
||||
|
||||
if (! class_exists($userClass)) {
|
||||
throw new Exception('No [' . $userClass . '] model found. Please bind an authenticatable model to the [Illuminate\\Contracts\\Auth\\Authenticatable] interface in a service provider\'s [register()] method.');
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Forms\Commands;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Commands\FileGenerators\FormSchemaClassGenerator;
|
||||
use Filament\Support\Commands\Concerns\CanAskForComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
@@ -82,7 +81,7 @@ class MakeFormCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -135,7 +134,7 @@ class MakeFormCommand extends Command
|
||||
->studly()
|
||||
->replace('/', '\\');
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
|
||||
@@ -165,7 +164,7 @@ class MakeFormCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Forms\Commands;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Commands\FileGenerators\LivewireFormComponentClassGenerator;
|
||||
use Filament\Support\Commands\Concerns\CanAskForLivewireComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanAskForViewLocation;
|
||||
@@ -110,7 +109,7 @@ class MakeLivewireFormCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -167,7 +166,7 @@ class MakeLivewireFormCommand extends Command
|
||||
->studly()
|
||||
->replace('/', '\\');
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
|
||||
@@ -197,7 +196,7 @@ class MakeLivewireFormCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Commands\FileGenerators;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
@@ -121,12 +120,12 @@ class PanelProviderClassGenerator extends ClassGenerator
|
||||
->colors([
|
||||
'primary' => {$this->simplifyFqn(Color::class)}::Amber,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/{$componentsDirectory}Resources'), for: {$this->simplifyFqn(Filament::class)}::namespaceFor('Filament\\{$componentsNamespace}Resources'))
|
||||
->discoverPages(in: app_path('Filament/{$componentsDirectory}Pages'), for: {$this->simplifyFqn(Filament::class)}::namespaceFor('Filament\\{$componentsNamespace}Pages'))
|
||||
->discoverResources(in: app_path('Filament/{$componentsDirectory}Resources'), for: {$this->simplifyFqn(app()->getNamespace() . "Filament\\{$componentsNamespace}Resources")})
|
||||
->discoverPages(in: app_path('Filament/{$componentsDirectory}Pages'), for: {$this->simplifyFqn(app()->getNamespace() . "Filament\\{$componentsNamespace}Pages")})
|
||||
->pages([
|
||||
{$this->simplifyFqn(Dashboard::class)}::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/{$componentsDirectory}Widgets'), for: {$this->simplifyFqn(Filament::class)}::namespaceFor('Filament\\{$componentsNamespace}Widgets'))
|
||||
->discoverWidgets(in: app_path('Filament/{$componentsDirectory}Widgets'), for: {$this->simplifyFqn(app()->getNamespace() . "Filament\\{$componentsNamespace}Widgets")})
|
||||
->widgets([
|
||||
{$this->simplifyFqn(AccountWidget::class)}::class,
|
||||
{$this->simplifyFqn(FilamentInfoWidget::class)}::class,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Commands;
|
||||
|
||||
use Filament\Commands\FileGenerators\ClusterClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Concerns\HasPanel;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
@@ -160,7 +159,7 @@ class MakeClusterCommand extends Command
|
||||
}
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
$this->clustersNamespace = (Arr::first($namespaces) ?? Filament::namespaceFor('Filament\\Clusters'));
|
||||
$this->clustersNamespace = (Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Clusters');
|
||||
$this->clustersDirectory = (Arr::first($directories) ?? app_path('Filament/Clusters/'));
|
||||
|
||||
return;
|
||||
|
||||
@@ -8,7 +8,6 @@ use Filament\Commands\FileGenerators\Resources\Pages\ResourceCustomPageClassGene
|
||||
use Filament\Commands\FileGenerators\Resources\Pages\ResourceEditRecordPageClassGenerator;
|
||||
use Filament\Commands\FileGenerators\Resources\Pages\ResourceManageRelatedRecordsPageClassGenerator;
|
||||
use Filament\Commands\FileGenerators\Resources\Pages\ResourceViewRecordPageClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Resources\Pages\ManageRelatedRecords;
|
||||
@@ -150,7 +149,7 @@ class MakePageCommand extends Command
|
||||
name: 'resource-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_OPTIONAL,
|
||||
description: 'The namespace of the resource class, such as [' . Filament::namespaceFor('Filament\\Resources') . ']',
|
||||
description: 'The namespace of the resource class, such as [' . app()->getNamespace() . 'Filament\\Resources]',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'type',
|
||||
@@ -337,7 +336,7 @@ class MakePageCommand extends Command
|
||||
}
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
$this->pagesNamespace = (Arr::first($namespaces) ?? Filament::namespaceFor('Filament\\Pages'));
|
||||
$this->pagesNamespace = (Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Pages');
|
||||
$this->pagesDirectory = (Arr::first($directories) ?? app_path('Filament/Pages/'));
|
||||
|
||||
return;
|
||||
@@ -585,7 +584,7 @@ class MakePageCommand extends Command
|
||||
$formSchemaFqn = $this->askForSchema(
|
||||
intialQuestion: 'Should an existing form schema class be used?',
|
||||
question: 'Which form schema class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Schemas\\UserForm'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Schemas\\UserForm',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -605,7 +604,7 @@ class MakePageCommand extends Command
|
||||
$infolistSchemaFqn = $this->askForSchema(
|
||||
intialQuestion: 'Would you like to use an existing infolist schema class?',
|
||||
question: 'Which infolist schema class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Schemas\\UserInfolist'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Schemas\\UserInfolist',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -622,7 +621,7 @@ class MakePageCommand extends Command
|
||||
$tableFqn = $this->askForSchema(
|
||||
intialQuestion: 'Would you like to use an existing table class?',
|
||||
question: 'Which table class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Tables\\UsersTable'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Tables\\UsersTable',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Commands;
|
||||
|
||||
use Filament\Commands\FileGenerators\Resources\RelationManagerClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForRelatedModel;
|
||||
use Filament\Support\Commands\Concerns\CanAskForRelatedResource;
|
||||
use Filament\Support\Commands\Concerns\CanAskForResource;
|
||||
@@ -207,7 +206,7 @@ class MakeRelationManagerCommand extends Command
|
||||
name: 'resource-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_OPTIONAL,
|
||||
description: 'The namespace of the resource class, such as [' . Filament::namespaceFor('Filament\\Resources') . ']',
|
||||
description: 'The namespace of the resource class, such as [' . app()->getNamespace() . 'Filament\\Resources]',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'soft-deletes',
|
||||
@@ -402,7 +401,7 @@ class MakeRelationManagerCommand extends Command
|
||||
: $this->askForSchema(
|
||||
intialQuestion: 'Would you like to use an existing form schema class?',
|
||||
question: 'Which form schema class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Schemas\\UserForm'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Schemas\\UserForm',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -465,7 +464,7 @@ class MakeRelationManagerCommand extends Command
|
||||
: $this->askForSchema(
|
||||
intialQuestion: 'Would you like to use an existing infolist schema class?',
|
||||
question: 'Which infolist schema class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Schemas\\UserInfolist'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Schemas\\UserInfolist',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -482,7 +481,7 @@ class MakeRelationManagerCommand extends Command
|
||||
: $this->askForSchema(
|
||||
intialQuestion: 'Would you like to use an existing table class?',
|
||||
question: 'Which table class would you like to use?',
|
||||
questionPlaceholder: Filament::namespaceFor('Filament\\Resources\\Users\\Tables\\UsersTable'),
|
||||
questionPlaceholder: app()->getNamespace() . 'Filament\\Resources\\Users\\Tables\\UsersTable',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ use Filament\Commands\FileGenerators\Resources\ResourceClassGenerator;
|
||||
use Filament\Commands\FileGenerators\Resources\Schemas\ResourceFormSchemaClassGenerator;
|
||||
use Filament\Commands\FileGenerators\Resources\Schemas\ResourceInfolistSchemaClassGenerator;
|
||||
use Filament\Commands\FileGenerators\Resources\Schemas\ResourceTableClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Pages\Page;
|
||||
use Filament\Support\Commands\Concerns\CanAskForResource;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
@@ -181,7 +180,7 @@ class MakeResourceCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'nested',
|
||||
@@ -212,7 +211,7 @@ class MakeResourceCommand extends Command
|
||||
name: 'resource-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_OPTIONAL,
|
||||
description: 'The namespace of the resource class, such as [' . Filament::namespaceFor('Filament\\Resources') . ']',
|
||||
description: 'The namespace of the resource class, such as [' . app()->getNamespace() . 'Filament\\Resources]',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'simple',
|
||||
@@ -302,7 +301,7 @@ class MakeResourceCommand extends Command
|
||||
$this->modelFqnEnd = 'Resource';
|
||||
}
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
} else {
|
||||
@@ -322,7 +321,7 @@ class MakeResourceCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -1053,13 +1053,4 @@ class FilamentManager
|
||||
{
|
||||
return $this->getCurrentOrDefaultPanel()->getErrorNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string|non-empty-string $namespace
|
||||
* @return class-string
|
||||
*/
|
||||
public function namespaceFor(string $namespace): string
|
||||
{
|
||||
return app()->getNamespace() . $namespace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Resources;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Panel;
|
||||
use Filament\Resources\RelationManagers\RelationGroup;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
@@ -77,7 +76,7 @@ abstract class Resource
|
||||
{
|
||||
return static::$model ?? (string) str(class_basename(static::class))
|
||||
->beforeLast('Resource')
|
||||
->prepend(Filament::namespaceFor('Models\\'));
|
||||
->prepend(app()->getNamespace() . 'Models\\');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Commands;
|
||||
|
||||
use Filament\Commands\FileGenerators\SettingsPageClassGenerator;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Concerns\HasCluster;
|
||||
use Filament\Support\Commands\Concerns\HasClusterPagesLocation;
|
||||
@@ -189,7 +188,7 @@ class MakeSettingsPageCommand extends Command
|
||||
|
||||
return array_filter($settingsFqns, fn (string $modelFqn): bool => str($modelFqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true));
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Settings\\SiteSettings'),
|
||||
placeholder: app()->getNamespace() . 'Settings\\SiteSettings',
|
||||
hint: 'Please provide the fully-qualified class name.',
|
||||
);
|
||||
}
|
||||
@@ -233,7 +232,7 @@ class MakeSettingsPageCommand extends Command
|
||||
}
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
$this->pagesNamespace = (Arr::first($namespaces) ?? Filament::namespaceFor('Filament\\Pages'));
|
||||
$this->pagesNamespace = (Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Pages');
|
||||
$this->pagesDirectory = (Arr::first($directories) ?? app_path('Filament/Pages/'));
|
||||
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Filament\Pages;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Concerns\CanUseDatabaseTransactions;
|
||||
use Filament\Pages\Concerns\HasUnsavedDataChangesAlert;
|
||||
@@ -147,7 +146,7 @@ class SettingsPage extends Page
|
||||
{
|
||||
return static::$settings ?? (string) str(class_basename(static::class))
|
||||
->beforeLast('Settings')
|
||||
->prepend(Filament::namespaceFor('Settings\\'))
|
||||
->prepend(app()->getNamespace() . 'Settings\\')
|
||||
->append('Settings');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Facades\FilamentCli;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
@@ -24,14 +23,14 @@ trait CanAskForComponentLocation
|
||||
|
||||
if (blank($locations)) {
|
||||
return [
|
||||
Filament::namespaceFor("Filament\\{$pathNamespace}"),
|
||||
app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
app_path('Filament' . DIRECTORY_SEPARATOR . $path),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
$options = [
|
||||
null => Filament::namespaceFor("Filament\\{$pathNamespace}"),
|
||||
null => app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
...array_map(
|
||||
fn (string $namespace): string => "{$namespace}\\{$pathNamespace}",
|
||||
array_combine(
|
||||
@@ -48,7 +47,7 @@ trait CanAskForComponentLocation
|
||||
|
||||
if (blank($namespace)) {
|
||||
return [
|
||||
Filament::namespaceFor("Filament\\{$pathNamespace}"),
|
||||
app()->getNamespace() . "Filament\\{$pathNamespace}",
|
||||
app_path('Filament' . DIRECTORY_SEPARATOR . $path),
|
||||
'',
|
||||
];
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Facades\FilamentCli;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
@@ -22,14 +21,14 @@ trait CanAskForLivewireComponentLocation
|
||||
|
||||
if (blank($locations)) {
|
||||
return [
|
||||
Filament::namespaceFor('Livewire'),
|
||||
app()->getNamespace() . 'Livewire',
|
||||
app_path('Livewire'),
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
$options = [
|
||||
null => Filament::namespaceFor('Livewire'),
|
||||
null => app()->getNamespace() . 'Livewire',
|
||||
...array_combine(
|
||||
array_keys($locations),
|
||||
array_keys($locations),
|
||||
@@ -43,7 +42,7 @@ trait CanAskForLivewireComponentLocation
|
||||
|
||||
if (blank($namespace)) {
|
||||
return [
|
||||
Filament::namespaceFor('Livewire'),
|
||||
app()->getNamespace() . 'Livewire',
|
||||
app_path('Livewire'),
|
||||
'',
|
||||
];
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use function Filament\Support\discover_app_classes;
|
||||
@@ -36,7 +35,7 @@ trait CanAskForRelatedModel
|
||||
|
||||
return array_filter($modelFqns, fn (string $modelFqn): bool => str($modelFqn)->replace(['\\', '/'], '')->contains($search, ignoreCase: true));
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\User'),
|
||||
placeholder: app()->getNamespace() . 'Models\\User',
|
||||
hint: 'Please provide the fully-qualified class name.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -61,7 +60,7 @@ trait CanAskForResource
|
||||
if (! $resourceFqns) {
|
||||
return (string) str(text(
|
||||
label: "No resources were found within [{$resourcesNamespace}]. {$question}",
|
||||
placeholder: Filament::namespaceFor('Filament\\Resources\\Posts\\PostResource'),
|
||||
placeholder: app()->getNamespace() . 'Filament\\Resources\\Posts\\PostResource',
|
||||
required: true,
|
||||
validate: function (string $value): ?string {
|
||||
$value = (string) str($value)
|
||||
|
||||
@@ -44,7 +44,7 @@ trait CanGeneratePanels
|
||||
throw new FailureCommandOutput;
|
||||
}
|
||||
|
||||
$fqn = Filament::namespaceFor("Providers\\Filament\\{$basename}");
|
||||
$fqn = app()->getNamespace() . "Providers\\Filament\\{$basename}";
|
||||
|
||||
if (empty(Filament::getPanels())) {
|
||||
$this->writeFile($path, app(PanelProviderClassGenerator::class, [
|
||||
@@ -71,8 +71,8 @@ trait CanGeneratePanels
|
||||
|
||||
if (! Str::contains($appConfig, "{$fqn}::class")) {
|
||||
file_put_contents(config_path('app.php'), str_replace(
|
||||
Filament::namespaceFor('Providers\\RouteServiceProvider') . '::class,',
|
||||
"{$fqn}::class," . PHP_EOL . ' ' . Filament::namespaceFor('Providers\\RouteServiceProvider') . '::class,',
|
||||
app()->getNamespace() . 'Providers\\RouteServiceProvider::class,',
|
||||
"{$fqn}::class," . PHP_EOL . ' ' . app()->getNamespace() . 'Providers\\RouteServiceProvider::class,',
|
||||
$appConfig,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Facades\Filament;
|
||||
use ReflectionClass;
|
||||
|
||||
use function Laravel\Prompts\confirm;
|
||||
@@ -58,7 +57,7 @@ trait HasCluster
|
||||
if (empty($clusterFqns)) {
|
||||
$clusterFqn = (string) str(text(
|
||||
label: "No clusters were found within the [{$this->panel->getId()}] panel. {$question}",
|
||||
placeholder: Filament::namespaceFor('Filament\\Clusters\\Blog'),
|
||||
placeholder: app()->getNamespace() . 'Filament\\Clusters\\Blog',
|
||||
required: true,
|
||||
validate: function (string $value): ?string {
|
||||
$value = (string) str($value)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Support\Commands\Concerns;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use function Laravel\Prompts\search;
|
||||
@@ -45,7 +44,7 @@ trait HasResourcesLocation
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
return [
|
||||
(Arr::first($namespaces) ?? Filament::namespaceFor('Filament\\Resources')),
|
||||
(Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Resources'),
|
||||
(Arr::first($directories) ?? app_path('Filament/Resources/')),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Tables\Commands;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForLivewireComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanAskForViewLocation;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
@@ -99,7 +98,7 @@ class MakeLivewireTableCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -154,7 +153,7 @@ class MakeLivewireTableCommand extends Command
|
||||
->studly()
|
||||
->replace('/', '\\');
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
|
||||
@@ -177,7 +176,7 @@ class MakeLivewireTableCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Tables\Commands;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanManipulateFiles;
|
||||
use Filament\Support\Commands\Exceptions\FailureCommandOutput;
|
||||
@@ -90,7 +89,7 @@ class MakeTableCommand extends Command
|
||||
name: 'model-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_REQUIRED,
|
||||
description: 'The namespace of the model class, [' . Filament::namespaceFor('Models') . '] by default',
|
||||
description: 'The namespace of the model class, [' . app()->getNamespace() . 'Models] by default',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'force',
|
||||
@@ -144,7 +143,7 @@ class MakeTableCommand extends Command
|
||||
->studly()
|
||||
->replace('/', '\\');
|
||||
|
||||
$modelNamespace = $this->option('model-namespace') ?? Filament::namespaceFor('Models');
|
||||
$modelNamespace = $this->option('model-namespace') ?? app()->getNamespace() . 'Models';
|
||||
|
||||
$this->modelFqn = "{$modelNamespace}\\{$this->modelFqnEnd}";
|
||||
|
||||
@@ -167,7 +166,7 @@ class MakeTableCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
required: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
// ...
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: Filament::namespaceFor('Filament\\Pages'))
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([]);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Filament\Widgets\Commands;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\Concerns\CanAskForLivewireComponentLocation;
|
||||
use Filament\Support\Commands\Concerns\CanAskForResource;
|
||||
use Filament\Support\Commands\Concerns\CanAskForViewLocation;
|
||||
@@ -140,7 +139,7 @@ class MakeWidgetCommand extends Command
|
||||
name: 'resource-namespace',
|
||||
shortcut: null,
|
||||
mode: InputOption::VALUE_OPTIONAL,
|
||||
description: 'The namespace of the resource class, such as [' . Filament::namespaceFor('Filament\\Resources') . ']',
|
||||
description: 'The namespace of the resource class, such as [' . app()->getNamespace() . 'Filament\\Resources]',
|
||||
),
|
||||
new InputOption(
|
||||
name: 'stats-overview',
|
||||
@@ -330,7 +329,7 @@ class MakeWidgetCommand extends Command
|
||||
}
|
||||
|
||||
if (count($namespaces) < 2) {
|
||||
$this->widgetsNamespace = (Arr::first($namespaces) ?? Filament::namespaceFor('Filament\\Widgets'));
|
||||
$this->widgetsNamespace = (Arr::first($namespaces) ?? app()->getNamespace() . 'Filament\\Widgets');
|
||||
$this->widgetsDirectory = (Arr::first($directories) ?? app_path('Filament/Widgets/'));
|
||||
|
||||
return;
|
||||
@@ -487,7 +486,7 @@ class MakeWidgetCommand extends Command
|
||||
fn (string $class): bool => str($class)->replace(['\\', '/'], '')->contains($search, ignoreCase: true),
|
||||
);
|
||||
},
|
||||
placeholder: Filament::namespaceFor('Models\\BlogPost'),
|
||||
placeholder: app()->getNamespace() . 'Models\\BlogPost',
|
||||
);
|
||||
|
||||
$isGenerated = confirm(
|
||||
|
||||
@@ -97,7 +97,7 @@ it('can generate a page class in a cluster', function (): void {
|
||||
$this->artisan('make:filament-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'--panel' => 'admin',
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -120,7 +120,7 @@ it('can generate a page view in a cluster', function (): void {
|
||||
$this->artisan('make:filament-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'--panel' => 'admin',
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -146,7 +146,7 @@ it('can generate a page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -179,7 +179,7 @@ it('can generate a page view in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -212,7 +212,7 @@ it('can generate a create page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -247,7 +247,7 @@ it('can generate an edit page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -282,7 +282,7 @@ it('can generate a view page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -334,8 +334,8 @@ $runGenerateManageRelatedRecordsPageCommand = function (TestCase $testCase): Pen
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\TeamResource'),
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\TeamResource',
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
return $testCase->artisan('make:filament-page', [
|
||||
@@ -385,8 +385,8 @@ it('can generate a manage related records page class in a resource with a relate
|
||||
$runGenerateManageRelatedRecordsPageCommand($this)
|
||||
->expectsQuestion($questions['relationship'], 'teams')
|
||||
->expectsQuestion($questions['hasRelatedResource'], true)
|
||||
->expectsQuestion($questions['relatedResource'], Filament::namespaceFor('Filament\\Resources\\TeamResource'))
|
||||
->expectsQuestion($questions['relatedResource'], Filament::namespaceFor('Filament\\Resources\\TeamResource')); // Repeat the question as there is a bug when testing `search()` in Prompts
|
||||
->expectsQuestion($questions['relatedResource'], app()->getNamespace() . 'Filament\\Resources\\TeamResource')
|
||||
->expectsQuestion($questions['relatedResource'], app()->getNamespace() . 'Filament\\Resources\\TeamResource'); // Repeat the question as there is a bug when testing `search()` in Prompts
|
||||
|
||||
assertFileExists($path = app_path('Filament/Resources/UserResource/Pages/ManageUserTeams.php'));
|
||||
expect(file_get_contents($path))
|
||||
|
||||
@@ -47,8 +47,8 @@ beforeEach(function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\TeamResource'),
|
||||
Filament::namespaceFor('Filament\\Resources\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\TeamResource',
|
||||
app()->getNamespace() . 'Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
MakeRelationManagerCommand::$shouldCheckModelsForSoftDeletes = false;
|
||||
@@ -74,7 +74,7 @@ it('can generate a relation manager with a related resource', function (): void
|
||||
$this->artisan('make:filament-relation-manager', [
|
||||
'resource' => 'Users',
|
||||
'relationship' => 'teams',
|
||||
'--related-resource' => Filament::namespaceFor('Filament\\Resources\\TeamResource'),
|
||||
'--related-resource' => app()->getNamespace() . 'Filament\\Resources\\TeamResource',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -8,7 +8,6 @@ use Carbon\CarbonInterface;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Commands\FileGenerators\FileGenerationFlag;
|
||||
use Filament\Tests\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -66,7 +65,7 @@ it('can generate a page class in a cluster', function (): void {
|
||||
$this->artisan('make:filament-settings-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'settings' => Settings::class,
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -88,7 +88,7 @@ it('can generate a page class in a cluster', function (): void {
|
||||
$this->artisan('make:filament-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'--panel' => 'admin',
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site\\SiteCluster'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site\\SiteCluster',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -111,7 +111,7 @@ it('can generate a page view in a cluster', function (): void {
|
||||
$this->artisan('make:filament-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'--panel' => 'admin',
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site\\SiteCluster'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site\\SiteCluster',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -137,7 +137,7 @@ it('can generate a page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -170,7 +170,7 @@ it('can generate a page view in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -203,7 +203,7 @@ it('can generate a create page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -238,7 +238,7 @@ it('can generate an edit page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -273,7 +273,7 @@ it('can generate a view page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-page', [
|
||||
@@ -325,8 +325,8 @@ $runGenerateManageRelatedRecordsPageCommand = function (TestCase $testCase): Pen
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Teams\\TeamResource'),
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Teams\\TeamResource',
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
return $testCase->artisan('make:filament-page', [
|
||||
@@ -384,8 +384,8 @@ it('can generate a manage related records page class in a resource with a relate
|
||||
$runGenerateManageRelatedRecordsPageCommand($this)
|
||||
->expectsQuestion($questions['relationship'], 'teams')
|
||||
->expectsQuestion($questions['hasRelatedResource'], true)
|
||||
->expectsQuestion($questions['relatedResource'], Filament::namespaceFor('Filament\\Resources\\Teams\\TeamResource'))
|
||||
->expectsQuestion($questions['relatedResource'], Filament::namespaceFor('Filament\\Resources\\Teams\\TeamResource')); // Repeat the question as there is a bug when testing `search()` in Prompts
|
||||
->expectsQuestion($questions['relatedResource'], app()->getNamespace() . 'Filament\\Resources\\Teams\\TeamResource')
|
||||
->expectsQuestion($questions['relatedResource'], app()->getNamespace() . 'Filament\\Resources\\Teams\\TeamResource'); // Repeat the question as there is a bug when testing `search()` in Prompts
|
||||
|
||||
assertFileExists($path = app_path('Filament/Resources/Users/Pages/ManageUserTeams.php'));
|
||||
expect(file_get_contents($path))
|
||||
@@ -399,7 +399,7 @@ it('can generate a manage related records page class in a resource with a form s
|
||||
->expectsQuestion($questions['relationship'], 'teams')
|
||||
->expectsQuestion($questions['hasRelatedResource'], false)
|
||||
->expectsQuestion($questions['hasFormSchemaClass'], true)
|
||||
->expectsQuestion($questions['formSchemaClass'], Filament::namespaceFor('Filament\\Resources\\Teams\\Schemas\\TeamForm'))
|
||||
->expectsQuestion($questions['formSchemaClass'], app()->getNamespace() . 'Filament\\Resources\\Teams\\Schemas\\TeamForm')
|
||||
->expectsQuestion($questions['hasViewOperation'], false)
|
||||
->expectsQuestion($questions['hasTableClass'], false)
|
||||
->expectsQuestion($questions['titleAttribute'], 'name')
|
||||
@@ -463,7 +463,7 @@ it('can generate a manage related records page class in a resource with an infol
|
||||
->expectsQuestion($questions['titleAttribute'], 'name')
|
||||
->expectsQuestion($questions['hasViewOperation'], true)
|
||||
->expectsQuestion($questions['hasInfolistSchemaClass'], true)
|
||||
->expectsQuestion($questions['infolistSchemaClass'], Filament::namespaceFor('Filament\\Resources\\Teams\\Schemas\\TeamInfolist'))
|
||||
->expectsQuestion($questions['infolistSchemaClass'], app()->getNamespace() . 'Filament\\Resources\\Teams\\Schemas\\TeamInfolist')
|
||||
->expectsQuestion($questions['hasTableClass'], false)
|
||||
->expectsQuestion($questions['isSoftDeletable'], false)
|
||||
->expectsQuestion($questions['relationshipType'], BelongsToMany::class);
|
||||
@@ -484,7 +484,7 @@ it('can generate a manage related records page class in a resource with a table
|
||||
->expectsQuestion($questions['titleAttribute'], 'name')
|
||||
->expectsQuestion($questions['hasViewOperation'], false)
|
||||
->expectsQuestion($questions['hasTableClass'], true)
|
||||
->expectsQuestion($questions['tableClass'], Filament::namespaceFor('Filament\\Resources\\Teams\\Tables\\TeamsTable'));
|
||||
->expectsQuestion($questions['tableClass'], app()->getNamespace() . 'Filament\\Resources\\Teams\\Tables\\TeamsTable');
|
||||
|
||||
assertFileExists($path = app_path('Filament/Resources/Users/Pages/ManageUserTeams.php'));
|
||||
expect(file_get_contents($path))
|
||||
@@ -546,7 +546,7 @@ it('can generate a custom record page class in a resource', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->mockConsoleOutput = true;
|
||||
|
||||
@@ -42,8 +42,8 @@ beforeEach(function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Teams\\TeamResource'),
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Teams\\TeamResource',
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
MakeRelationManagerCommand::$shouldCheckModelsForSoftDeletes = false;
|
||||
@@ -69,7 +69,7 @@ it('can generate a relation manager with a related resource', function (): void
|
||||
$this->artisan('make:filament-relation-manager', [
|
||||
'resource' => 'Users',
|
||||
'relationship' => 'teams',
|
||||
'--related-resource' => Filament::namespaceFor('Filament\\Resources\\Teams\\TeamResource'),
|
||||
'--related-resource' => app()->getNamespace() . 'Filament\\Resources\\Teams\\TeamResource',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
@@ -85,7 +85,7 @@ it('can generate a relation manager with a form schema class', function (): void
|
||||
'relationship' => 'teams',
|
||||
'recordTitleAttribute' => 'name',
|
||||
'--attach' => true,
|
||||
'--form-schema' => Filament::namespaceFor('Filament\\Resources\\Teams\\Schemas\\TeamForm'),
|
||||
'--form-schema' => app()->getNamespace() . 'Filament\\Resources\\Teams\\Schemas\\TeamForm',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
@@ -134,7 +134,7 @@ it('can generate a relation manager with an infolist schema class', function ():
|
||||
'relationship' => 'teams',
|
||||
'recordTitleAttribute' => 'name',
|
||||
'--attach' => true,
|
||||
'--infolist-schema' => Filament::namespaceFor('Filament\\Resources\\Teams\\Schemas\\TeamInfolist'),
|
||||
'--infolist-schema' => app()->getNamespace() . 'Filament\\Resources\\Teams\\Schemas\\TeamInfolist',
|
||||
'--view' => true,
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
@@ -151,7 +151,7 @@ it('can generate a relation manager with a table class', function (): void {
|
||||
'relationship' => 'teams',
|
||||
'recordTitleAttribute' => 'name',
|
||||
'--attach' => true,
|
||||
'--table' => Filament::namespaceFor('Filament\\Resources\\Teams\\Tables\\TeamsTable'),
|
||||
'--table' => app()->getNamespace() . 'Filament\\Resources\\Teams\\Tables\\TeamsTable',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -476,7 +476,7 @@ it('can generate a nested resource class', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -506,7 +506,7 @@ it('can generate a nested resource class with a plural parent resource name', fu
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -536,7 +536,7 @@ it('can generate a nested resource class with a parent resource name with `Resou
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -566,7 +566,7 @@ it('can generate a nested resource form', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -596,7 +596,7 @@ it('can generate a nested resource infolist', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -627,7 +627,7 @@ it('can generate a nested resource create page', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -657,7 +657,7 @@ it('can generate a nested resource edit page', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -687,7 +687,7 @@ it('can generate a nested resource view page', function (): void {
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
@@ -718,7 +718,7 @@ it('can generate a nested resource class in a nested directory', function (): vo
|
||||
|
||||
invade(Filament::getCurrentOrDefaultPanel())->resources = [
|
||||
...invade(Filament::getCurrentOrDefaultPanel())->resources,
|
||||
Filament::namespaceFor('Filament\\Resources\\Users\\UserResource'),
|
||||
app()->getNamespace() . 'Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
$this->artisan('make:filament-resource', [
|
||||
|
||||
@@ -8,7 +8,6 @@ use Carbon\CarbonInterface;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tests\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
use Spatie\LaravelSettings\Settings as BaseSettings;
|
||||
@@ -60,7 +59,7 @@ it('can generate a page class in a cluster', function (): void {
|
||||
$this->artisan('make:filament-settings-page', [
|
||||
'name' => 'ManageSettings',
|
||||
'settings' => Settings::class,
|
||||
'--cluster' => Filament::namespaceFor('Filament\\Clusters\\Site\\SiteCluster'),
|
||||
'--cluster' => app()->getNamespace() . 'Filament\\Clusters\\Site\\SiteCluster',
|
||||
'--panel' => 'admin',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tests\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
@@ -76,7 +75,7 @@ it('can generate a table class with a model in a custom namespace', function ():
|
||||
$this->artisan('make:filament-table', [
|
||||
'name' => 'PostsTable',
|
||||
'model' => 'Post',
|
||||
'--model-namespace' => Filament::namespaceFor('Models\\Blog'),
|
||||
'--model-namespace' => app()->getNamespace() . 'Models\\Blog',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tests\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
@@ -98,7 +97,7 @@ it('can generate a table widget class', function (): void {
|
||||
'--no-interaction' => true,
|
||||
])
|
||||
->expectsQuestion('Would you like to create this widget in a resource?', false)
|
||||
->expectsQuestion('What is the model?', Filament::namespaceFor('Models\\User'))
|
||||
->expectsQuestion('What is the model?', app()->getNamespace() . 'Models\\User')
|
||||
->expectsQuestion('Should the table columns be generated from the current database columns?', false);
|
||||
|
||||
assertFileExists($path = app_path('Filament/Widgets/TableWidget.php'));
|
||||
|
||||
Reference in New Issue
Block a user