From 93d36bd508d9375306c88c8bebd0fb582525ee50 Mon Sep 17 00:00:00 2001 From: Ryan Scherler Date: Wed, 15 Apr 2020 12:31:08 -0700 Subject: [PATCH] Refactor registering directives and components. --- ...04_10_100000_create_global_sets_table.php} | 4 +-- src/FilamentServiceProvider.php | 12 ++++---- src/Models/GlobalSet.php | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) rename database/migrations/{2020_04_10_100000_create_globals_table.php => 2020_04_10_100000_create_global_sets_table.php} (88%) create mode 100644 src/Models/GlobalSet.php diff --git a/database/migrations/2020_04_10_100000_create_globals_table.php b/database/migrations/2020_04_10_100000_create_global_sets_table.php similarity index 88% rename from database/migrations/2020_04_10_100000_create_globals_table.php rename to database/migrations/2020_04_10_100000_create_global_sets_table.php index 25b5d96ecb..04bec2ed3b 100644 --- a/database/migrations/2020_04_10_100000_create_globals_table.php +++ b/database/migrations/2020_04_10_100000_create_global_sets_table.php @@ -4,14 +4,14 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateGlobalsTable extends Migration +class CreateGlobalSetsTable extends Migration { /** * The name of the table for the migration. * * @var string */ - protected $tableName = 'globals'; + protected $tableName = 'global_sets'; /** * Run the migrations. diff --git a/src/FilamentServiceProvider.php b/src/FilamentServiceProvider.php index 9e3dd750ed..1a9cc05ced 100644 --- a/src/FilamentServiceProvider.php +++ b/src/FilamentServiceProvider.php @@ -35,6 +35,7 @@ class FilamentServiceProvider extends ServiceProvider $this->registerSingeltons(); $this->registerConfig(); $this->registerBindings(); + $this->registerBlade(); } /** @@ -52,7 +53,6 @@ class FilamentServiceProvider extends ServiceProvider $this->registerRoutes(); $this->registerMigrations(); $this->registerPublishing(); - $this->registerBlade(); $this->registerLivewire(); $this->registerResources(); $this->registerTranslations(); @@ -255,16 +255,18 @@ class FilamentServiceProvider extends ServiceProvider */ public function registerBlade() { - // Register package directives + // Register directives Blade::directive('filamentAssets', [BladeDirectives::class, 'assets']); Blade::directive('pushonce', [BladeDirectives::class, 'pushOnce']); Blade::directive('endpushonce', [BladeDirectives::class, 'endPushOnce']); - // Automatically register package components + // Register components + $components = []; foreach (File::glob(__DIR__.'/Http/Components/*.php') as $path) { - $baseName = basename($path, '.php'); - Blade::component("\\Filament\\Http\\Components\\{$baseName}", 'filament-'.Str::of($baseName)->kebab()); + $baseName= basename($path, '.php'); + $components[] = "\\Filament\\Http\\Components\\{$baseName}"; } + $this->loadViewComponentsAs('filament', $components); } /** diff --git a/src/Models/GlobalSet.php b/src/Models/GlobalSet.php new file mode 100644 index 0000000000..2920887b11 --- /dev/null +++ b/src/Models/GlobalSet.php @@ -0,0 +1,28 @@ + 'array', + ]; + + public static function search($query) + { + return empty($query) ? static::query() + : static::where('id', $query) + ->orWhere('name', 'like', '%'.$query.'%') + ->orWhere('fields', 'like', '%'.$query.'%'); + } +} \ No newline at end of file