mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Refactor registering directives and components.
This commit is contained in:
+2
-2
@@ -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.
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Filament\Traits\FillsColumns;
|
||||
|
||||
class GlobalSet extends Model
|
||||
{
|
||||
use FillsColumns;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'fields' => 'array',
|
||||
];
|
||||
|
||||
public static function search($query)
|
||||
{
|
||||
return empty($query) ? static::query()
|
||||
: static::where('id', $query)
|
||||
->orWhere('name', 'like', '%'.$query.'%')
|
||||
->orWhere('fields', 'like', '%'.$query.'%');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user