Start tables package

This commit is contained in:
Dan Harrin
2021-02-15 19:02:36 +00:00
parent 17859347ea
commit c10aa01bfb
45 changed files with 280 additions and 208 deletions
+3 -3
View File
@@ -37,7 +37,7 @@
"psr-4": {
"Filament\\": [
"packages/forms/src",
"packages/support/src",
"packages/tables/src",
"src"
],
"Filament\\Database\\Factories\\": "database/factories"
@@ -53,7 +53,7 @@
"providers": [
"Filament\\FilamentServiceProvider",
"Filament\\FormsServiceProvider",
"Filament\\SupportServiceProvider"
"Filament\\TablesServiceProvider"
],
"aliases": {
"FilamentManager": "Filament\\Filament"
@@ -62,7 +62,7 @@
},
"replace": {
"filament/forms": "self.version",
"filament/support": "self.version"
"filament/tables": "self.version"
},
"config": {
"sort-packages": true
+1 -2
View File
@@ -11,7 +11,6 @@
"php": "^7.4|^8.0",
"blade-ui-kit/blade-heroicons": "^0.3",
"danharrin/date-format-converter": "^0.2.0",
"filament/support": "^1.0",
"illuminate/database": "^8.0",
"illuminate/http": "^8.0",
"illuminate/support": "^8.0",
@@ -26,7 +25,7 @@
"extra": {
"laravel": {
"providers": [
"Filament\\FormsServiceProvider"
"TablesServiceProvider"
]
}
},
@@ -9,11 +9,11 @@
{{ $attributes }}
>
@if (count($fields))
<x-filament::form-grid :columns="$columns">
<x-forms::grid :columns="$columns">
@foreach ($fields as $field)
{{ $field->render() }}
@endforeach
</x-filament::form-grid>
</x-forms::grid>
@endif
{{ $slot }}
@@ -5,11 +5,11 @@
<div {{ $attributes }}>
@if (count($fields))
<x-filament::form-grid :columns="$columns">
<x-forms::grid :columns="$columns">
@foreach ($fields as $field)
{{ $field->render() }}
@endforeach
</x-filament::form-grid>
</x-forms::grid>
@endif
{{ $slot }}
@@ -4,11 +4,11 @@
'tabs' => [],
])
<x-filament::card
<div
x-data="{ tab: '{{ count($tabs) ? array_key_first($tabs) : null }}', tabs: {{ json_encode($tabs) }} }"
x-on:switch-tab.window="if ($event.detail in tabs) tab = $event.detail"
x-cloak
class="overflow-hidden"
class="overflow-hidden bg-white shadow-xl rounded p-4 md:p-6"
>
<div class="-m-4 md:-m-6">
<div {!! $label ? "aria-label=\"{$label}\"" : null !!} role="tablist" class="bg-gray-100 border-b border-gray-200 flex">
@@ -29,4 +29,4 @@
{{ $slot }}
</div>
</x-filament::card>
</div>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -7,7 +7,7 @@
:required="$field->required"
>
<x-slot name="labelPrefix">
<x-filament::checkbox
<x-forms::checkbox
:autofocus="$field->autofocus"
:disabled="$field->disabled"
:error-key="$field->name"
@@ -18,4 +18,4 @@
:required="$field->required"
/>
</x-slot>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::date-time-picker
<x-forms::date-time-picker
:autofocus="$field->autofocus"
:disabled="$field->disabled"
:display-format="convert_date_format($field->displayFormat)->to('day.js')"
@@ -23,4 +23,4 @@
:time="true"
:without-seconds="$field->withoutSeconds"
/>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::date-time-picker
<x-forms::date-time-picker
:autofocus="$field->autofocus"
:disabled="$field->disabled"
:display-format="convert_date_format($field->displayFormat)->to('day.js')"
@@ -22,4 +22,4 @@
:required="$field->required"
:time="false"
/>
</x-filament::field-group>
</x-forms::field-group>
@@ -5,5 +5,5 @@
</legend>
@endif
<x-filament::subform :fields="$field->fields" :columns="$field->columns" />
<x-forms::section :fields="$field->fields" :columns="$field->columns" />
</fieldset>
@@ -40,7 +40,7 @@
$field->placeholder = __($field->placeholder);
@endphp
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -127,4 +127,4 @@
type="file"
/>
</div>
</x-filament::field-group>
</x-forms::field-group>
@@ -28,7 +28,7 @@
</script>
@endpushonce
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -222,4 +222,4 @@
<div x-html="value" class="p-3 rounded shadow-sm border border-gray-300 prose"></div>
@endunless
</div>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::select
<x-forms::select
:autofocus="$field->autofocus"
:disabled="$field->disabled"
:empty-option-label="__($field->emptyOptionLabel)"
@@ -20,4 +20,4 @@
:placeholder="__($field->placeholder)"
:required="$field->required"
/>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,3 +1,3 @@
<x-filament::tab-content :id="$field->parentField->id . '.' . $field->id">
<x-filament::subform :fields="$field->fields" />
</x-filament::tab-content>
<x-forms::tab-content :id="$field->parentField->id . '.' . $field->id">
<x-forms::section :fields="$field->fields" />
</x-forms::tab-content>
@@ -1,5 +1,5 @@
<x-filament::tabs :id="$field->id" :label="__($field->label)" :tabs="$field->getTabsConfig()">
<x-forms::tabs :id="$field->id" :label="__($field->label)" :tabs="$field->getTabsConfig()">
@foreach($field->fields as $tab)
{{ $tab->render() }}
@endforeach
</x-filament::tabs>
</x-forms::tabs>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::tags
<x-forms::tags-input
:autofocus="$field->autofocus"
:disabled="$field->disabled"
:error-key="$field->name"
@@ -18,4 +18,4 @@
:required="$field->required"
:separator="$field->separator"
/>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::input
<x-forms::text-input
:autocomplete="$field->autocomplete"
:autofocus="$field->autofocus"
:disabled="$field->disabled"
@@ -21,4 +21,4 @@
:required="$field->required"
:type="$field->type"
/>
</x-filament::field-group>
</x-forms::field-group>
@@ -1,4 +1,4 @@
<x-filament::field-group
<x-forms::field-group
:error-key="$field->name"
:for="$field->id"
:help-message="__($field->helpMessage)"
@@ -6,7 +6,7 @@
:label="__($field->label)"
:required="$field->required"
>
<x-filament::textarea
<x-forms::textarea
:autocomplete="$field->autocomplete"
:autofocus="$field->autofocus"
:disabled="$field->disabled"
@@ -17,4 +17,4 @@
:name-attribute="$field->nameAttribute"
:placeholder="__($field->placeholder)"
/>
</x-filament::field-group>
</x-forms::field-group>
+1 -1
View File
@@ -240,7 +240,7 @@ class Field
{
if ($this->hidden) return;
$view = $this->view ?? 'filament::fields.' . Str::of(class_basename(static::class))->kebab();
$view = $this->view ?? 'forms::fields.' . Str::of(class_basename(static::class))->kebab();
return view($view, ['field' => $this]);
}
-5
View File
@@ -102,9 +102,4 @@ class Form
{
$this->rules = $rules;
}
public function render()
{
return view('filament::components.fields');
}
}
+84 -8
View File
@@ -2,15 +2,20 @@
namespace Filament;
use Filament\Support\Providers\ServiceProvider;
use Filament\Support\RegistersLivewireComponentDirectories;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Livewire\Component;
use Livewire\Livewire;
use Symfony\Component\Finder\SplFileInfo;
class FormsServiceProvider extends ServiceProvider
{
use RegistersLivewireComponentDirectories;
public function boot()
{
$this->bootDirectives();
$this->bootLoaders();
$this->bootLivewireComponents();
$this->bootPublishing();
@@ -21,16 +26,29 @@ class FormsServiceProvider extends ServiceProvider
$this->mergeConfigFrom(__DIR__ . '/../config/forms.php', 'forms');
}
protected function bootDirectives()
{
Blade::directive('pushonce', function ($expression) {
[$pushName, $pushSub] = explode(':', trim(substr($expression, 1, -1)));
$key = '__pushonce_' . str_replace('-', '_', $pushName) . '_' . str_replace('-', '_', $pushSub);
return "<?php if(! isset(\$__env->{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>";
});
Blade::directive('endpushonce', function () {
return '<?php $__env->stopPush(); endif; ?>';
});
}
protected function bootLoaders()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'filament');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'forms');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'forms');
}
protected function bootLivewireComponents()
{
$this->registerLivewireComponentDirectory(__DIR__ . '/Http/Livewire', 'Filament\\Forms\\Http\\Livewire', 'filament.forms.');
$this->registerLivewireComponentDirectory(__DIR__ . '/Http/Livewire', 'Filament\\Forms\\Http\\Livewire', 'forms.');
}
protected function bootPublishing()
@@ -44,11 +62,69 @@ class FormsServiceProvider extends ServiceProvider
], 'forms-config');
$this->publishes([
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/filament'),
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/forms'),
], 'forms-lang');
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/filament'),
__DIR__ . '/../resources/views' => resource_path('views/vendor/forms'),
], 'forms-views');
}
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, $this->mergeConfig(require $path, $config));
}
protected function mergeConfig(array $original, array $merging)
{
$array = array_merge($original, $merging);
foreach ($original as $key => $value) {
if (! is_array($value)) {
continue;
}
if (! Arr::exists($merging, $key)) {
continue;
}
if (is_numeric($key)) {
continue;
}
$array[$key] = $this->mergeConfig($value, $merging[$key]);
}
return $array;
}
protected function registerLivewireComponentDirectory($directory, $namespace, $aliasPrefix = '')
{
$filesystem = new Filesystem();
if (! $filesystem->isDirectory($directory)) return;
collect($filesystem->allFiles($directory))
->map(function (SplFileInfo $file) use ($namespace) {
return (string) Str::of($namespace)
->append('\\', $file->getRelativePathname())
->replace(['/', '.php'], ['\\', '']);
})
->filter(function ($class) {
return is_subclass_of($class, Component::class) && ! (new \ReflectionClass($class))->isAbstract();
})
->each(function ($class) use ($namespace, $aliasPrefix) {
$alias = Str::of($class)
->after($namespace . '\\')
->replace(['/', '\\'], '.')
->prepend($aliasPrefix)
->explode('.')
->map([Str::class, 'kebab'])
->implode('.');
Livewire::component($alias, $class);
});
}
}
@@ -1,39 +0,0 @@
<?php
namespace Filament\Support\Providers;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
class ServiceProvider extends BaseServiceProvider
{
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, $this->mergeConfig(require $path, $config));
}
protected function mergeConfig(array $original, array $merging)
{
$array = array_merge($original, $merging);
foreach ($original as $key => $value) {
if (! is_array($value)) {
continue;
}
if (! Arr::exists($merging, $key)) {
continue;
}
if (is_numeric($key)) {
continue;
}
$array[$key] = $this->mergeConfig($value, $merging[$key]);
}
return $array;
}
}
@@ -1,40 +0,0 @@
<?php
namespace Filament\Support;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Livewire\Component;
use Livewire\Livewire;
use Symfony\Component\Finder\SplFileInfo;
trait RegistersLivewireComponentDirectories
{
protected function registerLivewireComponentDirectory($directory, $namespace, $aliasPrefix = '')
{
$filesystem = new Filesystem();
if (! $filesystem->isDirectory($directory)) return;
collect($filesystem->allFiles($directory))
->map(function (SplFileInfo $file) use ($namespace) {
return (string) Str::of($namespace)
->append('\\', $file->getRelativePathname())
->replace(['/', '.php'], ['\\', '']);
})
->filter(function ($class) {
return is_subclass_of($class, Component::class) && ! (new \ReflectionClass($class))->isAbstract();
})
->each(function ($class) use ($namespace, $aliasPrefix) {
$alias = Str::of($class)
->after($namespace . '\\')
->replace(['/', '\\'], '.')
->prepend($aliasPrefix)
->explode('.')
->map([Str::class, 'kebab'])
->implode('.');
Livewire::component($alias, $class);
});
}
}
@@ -1,48 +0,0 @@
<?php
namespace Filament;
use Filament\Support\Providers\RouteServiceProvider;
use Filament\Support\Providers\ServiceProvider;
use Illuminate\Support\Facades\Blade;
class SupportServiceProvider extends ServiceProvider
{
public function boot()
{
$this->bootDirectives();
$this->bootLoaders();
$this->bootPublishing();
}
protected function bootDirectives()
{
Blade::directive('pushonce', function ($expression) {
[$pushName, $pushSub] = explode(':', trim(substr($expression, 1, -1)));
$key = '__pushonce_' . str_replace('-', '_', $pushName) . '_' . str_replace('-', '_', $pushSub);
return "<?php if(! isset(\$__env->{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>";
});
Blade::directive('endpushonce', function () {
return '<?php $__env->stopPush(); endif; ?>';
});
}
protected function bootLoaders()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'filament');
}
protected function bootPublishing()
{
if (! $this->app->runningInConsole()) {
return;
}
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/filament'),
], 'filament-views');
}
}
@@ -1,5 +1,6 @@
{
"name": "filament/support",
"name": "filament/tables",
"description": "Effortlessly build TALL-powered tables.",
"license": "MIT",
"homepage": "https://github.com/laravel-filament/filament",
"support": {
@@ -8,7 +9,7 @@
},
"require": {
"php": "^7.4|^8.0",
"illuminate/filesystem": "^8.0",
"blade-ui-kit/blade-heroicons": "^0.3",
"illuminate/support": "^8.0",
"livewire/livewire": "^2.2"
},
@@ -20,7 +21,7 @@
"extra": {
"laravel": {
"providers": [
"Filament\\SupportServiceProvider"
"Filament\\TablesServiceProvider"
]
}
},
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace Filament;
trait HasTable
{
//
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace Filament;
class Table
{
//
}
@@ -0,0 +1,36 @@
<?php
namespace Filament;
use Illuminate\Support\ServiceProvider;
class TablesServiceProvider extends ServiceProvider
{
public function boot()
{
$this->bootLoaders();
$this->bootPublishing();
}
protected function bootLoaders()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'tables');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'tables');
}
protected function bootPublishing()
{
if (! $this->app->runningInConsole()) {
return;
}
$this->publishes([
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/tables'),
], 'tables-lang');
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/tables'),
], 'tables-views');
}
}
@@ -3,7 +3,7 @@
<x-filament::app-content>
<x-filament::card>
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button
type="submit"
color="primary"
@@ -11,7 +11,7 @@
>
Create
</x-filament::button>
</x-filament::form>
</x-forms::container>
</x-filament::card>
</x-filament::app-content>
</div>
@@ -42,7 +42,7 @@
<x-filament::app-content>
<x-filament::card>
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button
type="submit"
color="primary"
@@ -50,7 +50,7 @@
>
Update
</x-filament::button>
</x-filament::form>
</x-forms::container>
</x-filament::card>
</x-filament::app-content>
</div>
+2 -2
View File
@@ -1,8 +1,8 @@
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button type="submit" color="primary" class="w-full" wire:loading.attr="disabled">
<x-filament::loader class="w-6 h-6 absolute left-0 ml-2 pointer-events-none" wire:loading />
{{ __('filament::auth.login') }}
</x-filament::button>
</x-filament::form>
</x-forms::container>
+2 -2
View File
@@ -1,7 +1,7 @@
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button type="submit" color="primary" class="w-full" wire:loading.attr="disabled">
<x-filament::loader class="w-6 h-6 absolute left-0 ml-2 pointer-events-none" wire:loading />
{{ __('filament::auth.register') }}
</x-filament::button>
</x-filament::form>
</x-forms::container>
@@ -1,7 +1,7 @@
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button type="submit" color="primary" class="w-full" wire:loading.attr="disabled">
<x-filament::loader class="w-6 h-6 absolute left-0 ml-2 pointer-events-none" wire:loading />
{{ __('filament::auth.sendPasswordReset') }}
</x-filament::button>
</x-filament::form>
</x-forms::container>
@@ -1,7 +1,7 @@
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button type="submit" color="primary" class="w-full" wire:loading.attr="disabled">
<x-filament::loader class="w-6 h-6 absolute left-0 ml-2 pointer-events-none" wire:loading />
{{ __('filament::auth.resetPassword') }}
</x-filament::button>
</x-filament::form>
</x-forms::container>
@@ -9,7 +9,7 @@
<div class="space-y-4">
<div class="flex items-center justify-between space-x-4">
<div class="relative flex-grow max-w-screen-md">
<x-filament::input
<x-forms::text-input
type="search"
model="search"
:placeholder="__('filament::datatable.search', ['resource' => Str::plural($resource)])"

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 521 B

+2 -2
View File
@@ -3,7 +3,7 @@
<x-filament::app-content>
<x-filament::card>
<x-filament::form :fields="$this->getForm()->fields" class="space-y-6">
<x-forms::container :fields="$this->getForm()->fields" class="space-y-6">
<x-filament::button
type="submit"
color="primary"
@@ -11,7 +11,7 @@
>
{{ __('filament::edit-account.update') }}
</x-filament::button>
</x-filament::form>
</x-forms::container>
</x-filament::card>
</x-filament::app-content>
</div>
+81 -5
View File
@@ -6,16 +6,20 @@ use Filament\Commands\MakeUserCommand;
use Filament\Http\Middleware\AuthorizeResourceRoute;
use Filament\Models\FilamentUser;
use Filament\Providers\RouteServiceProvider;
use Filament\Support\Providers\ServiceProvider;
use Filament\Support\RegistersLivewireComponentDirectories;
use Filament\View\Components;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Routing\Router;
use BladeUI\Icons\Factory as BladeUIFactory;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Livewire\Component;
use Livewire\Livewire;
use Symfony\Component\Finder\SplFileInfo;
class FilamentServiceProvider extends ServiceProvider
{
use RegistersLivewireComponentDirectories;
public $singletons = [
FilamentManager::class => FilamentManager::class,
Navigation::class => Navigation::class,
@@ -24,6 +28,7 @@ class FilamentServiceProvider extends ServiceProvider
public function boot()
{
$this->bootCommands();
$this->bootDirectives();
$this->bootLoaders();
$this->bootLivewireComponents();
$this->bootMiddleware();
@@ -53,6 +58,19 @@ class FilamentServiceProvider extends ServiceProvider
]);
}
protected function bootDirectives()
{
Blade::directive('pushonce', function ($expression) {
[$pushName, $pushSub] = explode(':', trim(substr($expression, 1, -1)));
$key = '__pushonce_' . str_replace('-', '_', $pushName) . '_' . str_replace('-', '_', $pushSub);
return "<?php if(! isset(\$__env->{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>";
});
Blade::directive('endpushonce', function () {
return '<?php $__env->stopPush(); endif; ?>';
});
}
protected function bootLoaders()
{
$this->loadViewComponentsAs('filament', [
@@ -141,11 +159,69 @@ class FilamentServiceProvider extends ServiceProvider
'path' => __DIR__ . '/../resources/svg',
'prefix' => 'filamenticon',
]);
});
});
}
protected function registerProviders()
{
$this->app->register(RouteServiceProvider::class);
}
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, $this->mergeConfig(require $path, $config));
}
protected function mergeConfig(array $original, array $merging)
{
$array = array_merge($original, $merging);
foreach ($original as $key => $value) {
if (! is_array($value)) {
continue;
}
if (! Arr::exists($merging, $key)) {
continue;
}
if (is_numeric($key)) {
continue;
}
$array[$key] = $this->mergeConfig($value, $merging[$key]);
}
return $array;
}
protected function registerLivewireComponentDirectory($directory, $namespace, $aliasPrefix = '')
{
$filesystem = new Filesystem();
if (! $filesystem->isDirectory($directory)) return;
collect($filesystem->allFiles($directory))
->map(function (SplFileInfo $file) use ($namespace) {
return (string) Str::of($namespace)
->append('\\', $file->getRelativePathname())
->replace(['/', '.php'], ['\\', '']);
})
->filter(function ($class) {
return is_subclass_of($class, Component::class) && ! (new \ReflectionClass($class))->isAbstract();
})
->each(function ($class) use ($namespace, $aliasPrefix) {
$alias = Str::of($class)
->after($namespace . '\\')
->replace(['/', '\\'], '.')
->prepend($aliasPrefix)
->explode('.')
->map([Str::class, 'kebab'])
->implode('.');
Livewire::component($alias, $class);
});
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
\BladeUI\Icons\BladeIconsServiceProvider::class,
\Filament\FilamentServiceProvider::class,
\Filament\FormsServiceProvider::class,
\Filament\SupportServiceProvider::class,
\Filament\TablesServiceProvider::class,
\Livewire\LivewireServiceProvider::class,
\Thomaswelton\LaravelGravatar\LaravelGravatarServiceProvider::class,
\Watson\Active\ActiveServiceProvider::class,