mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
wip
This commit is contained in:
@@ -8,7 +8,6 @@ use Filament\SpatieLaravelTranslatablePluginServiceProvider;
|
||||
use Filament\Support\SupportServiceProvider;
|
||||
use Filament\Tables\TablesServiceProvider;
|
||||
use Filament\Tests\AdminFilamentProvider;
|
||||
use Filament\Tests\App\Navigation\NavigationServiceProvider;
|
||||
use Filament\Widgets\WidgetsServiceProvider;
|
||||
use Livewire\LivewireServiceProvider;
|
||||
use Orchestra\Testbench\Concerns\CreatesApplication;
|
||||
@@ -30,7 +29,6 @@ $app->register(LivewireServiceProvider::class);
|
||||
$app->register(FilamentServiceProvider::class);
|
||||
$app->register(ActionsServiceProvider::class);
|
||||
$app->register(FormsServiceProvider::class);
|
||||
$app->register(NavigationServiceProvider::class);
|
||||
$app->register(NotificationsServiceProvider::class);
|
||||
$app->register(SpatieLaravelTranslatablePluginServiceProvider::class);
|
||||
$app->register(SupportServiceProvider::class);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Filament;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Filament\AvatarProviders\UiAvatarsProvider;
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\GlobalSearch\Contracts\GlobalSearchProvider;
|
||||
use Filament\GlobalSearch\DefaultGlobalSearchProvider;
|
||||
@@ -118,6 +119,8 @@ class Context
|
||||
|
||||
protected ?string $googleFonts = 'https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap';
|
||||
|
||||
protected array $plugins = [];
|
||||
|
||||
public function default(bool $condition = true): static
|
||||
{
|
||||
$this->isDefault = $condition;
|
||||
@@ -146,6 +149,10 @@ class Context
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
foreach ($this->plugins as $plugin) {
|
||||
$plugin->register($this);
|
||||
}
|
||||
|
||||
$this->registerLivewireComponents();
|
||||
}
|
||||
|
||||
@@ -406,6 +413,23 @@ class Context
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function plugin(Plugin $plugin): static
|
||||
{
|
||||
$this->plugins[] = $plugin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function plugins(array $plugins): static
|
||||
{
|
||||
$this->plugins = array_merge(
|
||||
$this->plugins,
|
||||
$plugins,
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasRoutableTenancy(): bool
|
||||
{
|
||||
/** @var EloquentUserProvider $userProvider */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Contracts;
|
||||
|
||||
use Filament\Context;
|
||||
|
||||
interface Plugin
|
||||
{
|
||||
public function register(Context $context): void;
|
||||
}
|
||||
@@ -54,24 +54,13 @@ use Illuminate\Support\Facades\Facade;
|
||||
* @method static string getUserName(Model | Authenticatable $user)
|
||||
* @method static array getUserTenants(HasTenants | Model | Authenticatable $user)
|
||||
* @method static array getWidgets()
|
||||
* @method static void globalSearchProvider(string $provider, ?string $context = null)
|
||||
* @method static bool hasDarkMode()
|
||||
* @method static bool hasDatabaseNotifications()
|
||||
* @method static bool hasLogin()
|
||||
* @method static bool hasTenancy()
|
||||
* @method static bool hasTenantRegistration()
|
||||
* @method static bool hasRoutableTenancy()
|
||||
* @method static void navigation(Closure $builder, ?string $context = null)
|
||||
* @method static void registerContext(Context $context)
|
||||
* @method static void registerNavigationGroups(array $groups, ?string $context = null)
|
||||
* @method static void registerNavigationItems(array $items, ?string $context = null)
|
||||
* @method static void registerPages(array $pages, ?string $context = null)
|
||||
* @method static void registerRenderHook(string $name, Closure $callback, ?string $context = null)
|
||||
* @method static void registerResources(array $resources, ?string $context = null)
|
||||
* @method static void registerTenantMenuItems(array $items, ?string $context = null)
|
||||
* @method static void registerTheme(string | Htmlable | null $theme, ?string $context = null)
|
||||
* @method static void registerUserMenuItems(array $items, ?string $context = null)
|
||||
* @method static void registerWidgets(array $widgets, ?string $context = null)
|
||||
* @method static Htmlable renderHook(string $name)
|
||||
* @method static void serving(Closure $callback)
|
||||
* @method static void setCurrentContext(Context | null $context = null)
|
||||
|
||||
@@ -39,21 +39,11 @@ class FilamentManager
|
||||
$this->getCurrentContext()->boot();
|
||||
}
|
||||
|
||||
public function navigation(Closure $builder, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->navigation($builder);
|
||||
}
|
||||
|
||||
public function buildNavigation(): array
|
||||
{
|
||||
return $this->getCurrentContext()->buildNavigation();
|
||||
}
|
||||
|
||||
public function globalSearchProvider(string $provider, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->globalSearchProvider($provider);
|
||||
}
|
||||
|
||||
public function mountNavigation(): void
|
||||
{
|
||||
$this->getCurrentContext()->mountNavigation();
|
||||
@@ -68,72 +58,6 @@ class FilamentManager
|
||||
}
|
||||
}
|
||||
|
||||
public function registerNavigationGroups(array $groups, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->navigationGroups($groups);
|
||||
}
|
||||
|
||||
public function registerNavigationItems(array $items, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->navigationItems($items);
|
||||
}
|
||||
|
||||
public function registerPages(array $pages, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->pages($pages);
|
||||
}
|
||||
|
||||
public function registerRenderHook(string $name, Closure $callback, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->renderHook($name, $callback);
|
||||
}
|
||||
|
||||
public function registerResources(array $resources, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->resources($resources);
|
||||
}
|
||||
|
||||
public function registerTheme(string | Htmlable | null $theme, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->theme($theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `registerTheme()` instead.
|
||||
*/
|
||||
public function registerThemeUrl(string | Htmlable | null $theme): void
|
||||
{
|
||||
$this->registerTheme($theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `registerTheme()` instead.
|
||||
*/
|
||||
public function registerThemeLink(string | Htmlable | null $theme): void
|
||||
{
|
||||
$this->registerTheme($theme);
|
||||
}
|
||||
|
||||
public function registerTenantMenuItems(array $items, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->tenantMenuItems($items);
|
||||
}
|
||||
|
||||
public function registerUserMenuItems(array $items, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->userMenuItems($items);
|
||||
}
|
||||
|
||||
public function registerWidgets(array $widgets, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->widgets($widgets);
|
||||
}
|
||||
|
||||
public function pushMeta(array $meta, ?string $context = null): void
|
||||
{
|
||||
$this->getContext($context)->meta($meta);
|
||||
}
|
||||
|
||||
public function favicon(?string $url): void
|
||||
{
|
||||
$this->favicon = $url;
|
||||
|
||||
@@ -52,6 +52,10 @@ abstract class Page extends Component implements HasActions, RendersFormComponen
|
||||
|
||||
protected ?string $maxContentWidth = null;
|
||||
|
||||
public static string $formActionsAlignment = 'left';
|
||||
|
||||
public static bool $hasInlineFormLabels = false;
|
||||
|
||||
public static function registerNavigationItems(): void
|
||||
{
|
||||
if (! static::shouldRegisterNavigation()) {
|
||||
@@ -279,4 +283,29 @@ abstract class Page extends Component implements HasActions, RendersFormComponen
|
||||
{
|
||||
throw new Halt();
|
||||
}
|
||||
|
||||
public static function alignFormActionsLeft(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'left';
|
||||
}
|
||||
|
||||
public static function alignFormActionsCenter(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'center';
|
||||
}
|
||||
|
||||
public static function alignFormActionsRight(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'right';
|
||||
}
|
||||
|
||||
public function getFormActionsAlignment(): string
|
||||
{
|
||||
return static::$formActionsAlignment;
|
||||
}
|
||||
|
||||
public function hasInlineFormLabels(): bool
|
||||
{
|
||||
return static::$hasInlineFormLabels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ abstract class Page extends BasePage
|
||||
|
||||
protected static string $resource;
|
||||
|
||||
public static string $formActionsAlignment = 'left';
|
||||
|
||||
public static bool $hasInlineFormLabels = false;
|
||||
|
||||
public static function route(string $path): PageRegistration
|
||||
{
|
||||
return new PageRegistration(
|
||||
@@ -80,29 +76,4 @@ abstract class Page extends BasePage
|
||||
|
||||
$this->{$hook}();
|
||||
}
|
||||
|
||||
public static function alignFormActionsLeft(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'left';
|
||||
}
|
||||
|
||||
public static function alignFormActionsCenter(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'center';
|
||||
}
|
||||
|
||||
public static function alignFormActionsRight(): void
|
||||
{
|
||||
static::$formActionsAlignment = 'right';
|
||||
}
|
||||
|
||||
public function getFormActionsAlignment(): string
|
||||
{
|
||||
return static::$formActionsAlignment;
|
||||
}
|
||||
|
||||
public function hasInlineFormLabels(): bool
|
||||
{
|
||||
return static::$hasInlineFormLabels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,6 @@ abstract class PluginServiceProvider extends PackageServiceProvider
|
||||
|
||||
protected string $context = 'default';
|
||||
|
||||
protected array $pages = [];
|
||||
|
||||
protected array $resources = [];
|
||||
|
||||
protected array $widgets = [];
|
||||
|
||||
public function configurePackage(Package $package): void
|
||||
{
|
||||
$this->packageConfiguring($package);
|
||||
@@ -66,20 +60,6 @@ abstract class PluginServiceProvider extends PackageServiceProvider
|
||||
}
|
||||
});
|
||||
|
||||
$this->app->afterResolving('filament', function () {
|
||||
Filament::registerPages($this->getPages(), $this->getContext());
|
||||
Filament::registerResources($this->getResources(), $this->getContext());
|
||||
Filament::registerWidgets($this->getWidgets(), $this->getContext());
|
||||
|
||||
Filament::serving(function () {
|
||||
if (Filament::getCurrentContext()->getId() !== $this->getContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Filament::registerUserMenuItems($this->getUserMenuItems(), $this->getContext());
|
||||
});
|
||||
});
|
||||
|
||||
$this->app->resolving(AssetManager::class, function () {
|
||||
FilamentAsset::register($this->getAssets(), $this->getAssetPackage());
|
||||
FilamentAsset::registerScriptData($this->getScriptData(), $this->getAssetPackage());
|
||||
@@ -125,16 +105,6 @@ abstract class PluginServiceProvider extends PackageServiceProvider
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getPages(): array
|
||||
{
|
||||
return $this->pages;
|
||||
}
|
||||
|
||||
protected function getResources(): array
|
||||
{
|
||||
return $this->resources;
|
||||
}
|
||||
|
||||
protected function getRoutes(): array
|
||||
{
|
||||
return [];
|
||||
@@ -145,16 +115,6 @@ abstract class PluginServiceProvider extends PackageServiceProvider
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getUserMenuItems(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getWidgets(): array
|
||||
{
|
||||
return $this->widgets;
|
||||
}
|
||||
|
||||
protected function registerMacros(): void
|
||||
{
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Table extends ViewComponent
|
||||
|
||||
protected array | Closure | null $contentGrid = null;
|
||||
|
||||
protected int | string | Closure | null $defaultPaginationPageOption = null;
|
||||
protected int | string | Closure | null $defaultPaginationPageOption = 10;
|
||||
|
||||
protected string | Closure | null $defaultSortColumn = null;
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\Actions;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
use Filament\Tests\Actions\Fixtures\Pages\Actions;
|
||||
|
||||
class ActionsServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'actions';
|
||||
|
||||
protected function getPages(): array
|
||||
{
|
||||
return [
|
||||
Actions::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
ActionsServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Http\Middleware\MirrorConfigToSubpackages;
|
||||
use Filament\Pages;
|
||||
use Filament\Tests\Actions\Fixtures\Pages\Actions;
|
||||
use Filament\Tests\App\Fixtures\Pages\Settings;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostCategoryResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\ProductResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\UserResource;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
@@ -24,8 +30,16 @@ class AdminFilamentProvider extends ContextProvider
|
||||
->default()
|
||||
->id('admin')
|
||||
->loginPage()
|
||||
->resources([
|
||||
PostResource::class,
|
||||
PostCategoryResource::class,
|
||||
ProductResource::class,
|
||||
UserResource::class,
|
||||
])
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
Actions::class,
|
||||
Settings::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\App\GlobalSearch;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostResource;
|
||||
|
||||
class GlobalSearchServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'global-search';
|
||||
|
||||
protected function getResources(): array
|
||||
{
|
||||
return [
|
||||
PostResource::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ it('can retrieve limited search results', function () {
|
||||
});
|
||||
|
||||
it('can retrieve results via custom search provider', function () {
|
||||
Filament::globalSearchProvider(CustomSearchProvider::class);
|
||||
Filament::getCurrentContext()->globalSearchProvider(CustomSearchProvider::class);
|
||||
|
||||
livewire(GlobalSearch::class)
|
||||
->set('search', 'foo')
|
||||
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
GlobalSearchServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use Filament\Tests\App\Navigation\TestCase;
|
||||
uses(TestCase::class);
|
||||
|
||||
it('can register navigation', function () {
|
||||
Filament::navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
Filament::getCurrentContext()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
return $navigation
|
||||
->items([
|
||||
...Dashboard::getNavigationItems(),
|
||||
@@ -80,7 +80,7 @@ it('can register navigation', function () {
|
||||
});
|
||||
|
||||
it('can register navigation groups individually', function () {
|
||||
Filament::navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
Filament::getCurrentContext()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
return $navigation
|
||||
->group('Blog', [
|
||||
...PostResource::getNavigationItems(),
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\App\Navigation;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
use Filament\Tests\App\Fixtures\Pages\Settings;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostCategoryResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\ProductResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\UserResource;
|
||||
|
||||
class NavigationServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'navigation';
|
||||
|
||||
protected function getResources(): array
|
||||
{
|
||||
return [
|
||||
PostResource::class,
|
||||
PostCategoryResource::class,
|
||||
ProductResource::class,
|
||||
UserResource::class,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getPages(): array
|
||||
{
|
||||
return [
|
||||
Settings::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -14,46 +14,22 @@ it('can register navigation items from resources and pages', function () {
|
||||
->toBeInstanceOf(NavigationGroup::class)
|
||||
->getLabel()->toBeNull()
|
||||
->getItems()
|
||||
->sequence(
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Dashboard')
|
||||
->getIcon()->toBe('heroicon-o-home'),
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Users')
|
||||
->getIcon()->toBe('heroicon-o-user'),
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Settings')
|
||||
->getIcon()->toBe('heroicon-o-cog-6-tooth'),
|
||||
)
|
||||
->each->toBeInstanceOf(NavigationItem::class),
|
||||
fn ($group) => $group
|
||||
->toBeInstanceOf(NavigationGroup::class)
|
||||
->getLabel()->toBe('Blog')
|
||||
->getItems()
|
||||
->sequence(
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Posts')
|
||||
->getIcon()->toBe('heroicon-o-document-text'),
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Post Categories')
|
||||
->getIcon()->toBe('heroicon-o-rectangle-stack'),
|
||||
)
|
||||
->each->toBeInstanceOf(NavigationItem::class),
|
||||
fn ($group) => $group
|
||||
->toBeInstanceOf(NavigationGroup::class)
|
||||
->getLabel()->toBe('Shop')
|
||||
->getItems()
|
||||
->sequence(
|
||||
fn ($item) => $item
|
||||
->getLabel()->toBe('Products')
|
||||
->getIcon()->toBe('heroicon-o-shopping-bag'),
|
||||
)
|
||||
->each->toBeInstanceOf(NavigationItem::class),
|
||||
);
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering them', function () {
|
||||
Filament::registerNavigationGroups([
|
||||
Filament::getCurrentContext()->navigationGroups([
|
||||
NavigationGroup::make()->label('Shop'),
|
||||
NavigationGroup::make()->label('Blog'),
|
||||
]);
|
||||
@@ -73,7 +49,7 @@ it('can reorder navigation groups by registering them', function () {
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering them with different labels', function () {
|
||||
Filament::registerNavigationGroups([
|
||||
Filament::getCurrentContext()->navigationGroups([
|
||||
'Shop' => NavigationGroup::make()->label('Store'),
|
||||
'Blog' => NavigationGroup::make()->label('Posts'),
|
||||
]);
|
||||
@@ -93,7 +69,7 @@ it('can reorder navigation groups by registering them with different labels', fu
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering their labels', function () {
|
||||
Filament::registerNavigationGroups([
|
||||
Filament::getCurrentContext()->navigationGroups([
|
||||
'Shop',
|
||||
'Blog',
|
||||
]);
|
||||
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
NavigationServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\App\Pages;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
use Filament\Tests\App\Fixtures\Pages\Settings;
|
||||
|
||||
class PagesServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'pages';
|
||||
|
||||
protected function getPages(): array
|
||||
{
|
||||
return [
|
||||
Settings::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
PagesServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\App\RenderHooks;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
|
||||
class RenderHooksServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'render-hooks';
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\HtmlString;
|
||||
uses(TestCase::class);
|
||||
|
||||
test('render hooks can be registered', function () {
|
||||
Filament::registerRenderHook('foo', function (): string {
|
||||
Filament::getCurrentContext()->renderHook('foo', function (): string {
|
||||
return Blade::render('bar');
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ test('render hooks can be registered', function () {
|
||||
});
|
||||
|
||||
test('render hooks can render view files', function () {
|
||||
Filament::registerRenderHook('view-foo', function (): Illuminate\Contracts\View\View {
|
||||
Filament::getCurrentContext()->renderHook('view-foo', function (): Illuminate\Contracts\View\View {
|
||||
return view('app.fixtures.pages.render-hooks.foo');
|
||||
});
|
||||
|
||||
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
RenderHooksServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,6 @@ use function Pest\Livewire\livewire;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Filament::registerResources([
|
||||
PostResource::class,
|
||||
]);
|
||||
});
|
||||
|
||||
it('can render page', function () {
|
||||
$this->get(PostResource::getUrl('edit', [
|
||||
'record' => Post::factory()->create(),
|
||||
|
||||
@@ -9,12 +9,6 @@ use function Pest\Livewire\livewire;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Filament::registerResources([
|
||||
PostResource::class,
|
||||
]);
|
||||
});
|
||||
|
||||
it('can render page', function () {
|
||||
$this->get(PostResource::getUrl('view', [
|
||||
'record' => Post::factory()->create(),
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\App\Resources;
|
||||
|
||||
use Filament\Support\PluginServiceProvider;
|
||||
use Filament\Tests\App\Fixtures\Resources\PostResource;
|
||||
use Filament\Tests\App\Fixtures\Resources\UserResource;
|
||||
|
||||
class ResourcesServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
public static string $name = 'resources';
|
||||
|
||||
protected function getResources(): array
|
||||
{
|
||||
return [
|
||||
PostResource::class,
|
||||
UserResource::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,4 @@ class TestCase extends BaseTestCase
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return array_merge(parent::getPackageProviders($app), [
|
||||
ResourcesServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ use Filament\SpatieLaravelSettingsPluginServiceProvider;
|
||||
use Filament\SpatieLaravelTranslatablePluginServiceProvider;
|
||||
use Filament\Support\SupportServiceProvider;
|
||||
use Filament\Tables\TablesServiceProvider;
|
||||
use Filament\Tests\App\Navigation\NavigationServiceProvider;
|
||||
use Filament\Tests\Models\User;
|
||||
use Filament\Widgets\WidgetsServiceProvider;
|
||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||
@@ -34,7 +33,6 @@ abstract class TestCase extends BaseTestCase
|
||||
FilamentServiceProvider::class,
|
||||
FormsServiceProvider::class,
|
||||
LivewireServiceProvider::class,
|
||||
NavigationServiceProvider::class,
|
||||
NotificationsServiceProvider::class,
|
||||
SpatieLaravelSettingsPluginServiceProvider::class,
|
||||
SpatieLaravelTranslatablePluginServiceProvider::class,
|
||||
|
||||
Reference in New Issue
Block a user