diff --git a/composer.json b/composer.json index 5af839c..4f3020c 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "livewire", "utilities", "traits", + "concerns", "helpers" ], "homepage": "https://github.com/foxws/wireuse", @@ -27,7 +28,6 @@ "illuminate/view": "^10.0|^11.0", "laravel/scout": "^10.0|^11.0", "livewire/livewire": "^3.4", - "artesaos/seotools": "^1.3", "spatie/laravel-package-tools": "^1.16.5" }, "require-dev": { @@ -45,6 +45,7 @@ "spatie/php-structure-discoverer": "^2.1", "spatie/laravel-html": "^3.11", "spatie/laravel-model-states": "^2.7", + "artesaos/seotools": "^1.3", "blade-ui-kit/blade-icons": "^1.6.0" }, "autoload": { diff --git a/config/wireuse.php b/config/wireuse.php index b1bf958..bd67082 100644 --- a/config/wireuse.php +++ b/config/wireuse.php @@ -25,7 +25,7 @@ | | This extends Laravel HTML. | - | @doc https://foxws.nl/posts/wireuse/laravel-html + | @doc https://foxws.nl/posts/wireuse-laravel-html-spatie | @doc https://spatie.be/docs/laravel-html/v3 | */ @@ -41,7 +41,7 @@ | | This controls structure discovery. | - | @doc https://foxws.nl/posts/wireuse/structure-scout + | @doc https://foxws.nl/posts/wireuse-structure-scout | @doc https://github.com/spatie/php-structure-discoverer | */ diff --git a/src/Auth/Concerns/WithAuthorization.php b/src/Auth/Concerns/WithAuthorization.php index a570cfb..783d371 100644 --- a/src/Auth/Concerns/WithAuthorization.php +++ b/src/Auth/Concerns/WithAuthorization.php @@ -16,7 +16,9 @@ public function bootWithAuthorization(): void protected function authorizeAccess(): void { - // $this->canViewAny(Todo::class); + // $this->canViewAny(Post::class); + + // $this->canView($this->post); } protected function canViewAny(mixed $arguments): void diff --git a/src/Forms/Concerns/WithAttributes.php b/src/Forms/Concerns/WithAttributes.php index 07943ce..d481b26 100644 --- a/src/Forms/Concerns/WithAttributes.php +++ b/src/Forms/Concerns/WithAttributes.php @@ -65,7 +65,7 @@ public function clear(bool $submit = true): void protected function keys(): array { - return $this->request()->keys(); + return array_keys($this->all()); } protected function request(): FormRequest diff --git a/src/Forms/Concerns/WithSession.php b/src/Forms/Concerns/WithSession.php index c5f01a5..fc2b846 100644 --- a/src/Forms/Concerns/WithSession.php +++ b/src/Forms/Concerns/WithSession.php @@ -6,6 +6,10 @@ trait WithSession { protected static bool $store = false; + /** + * Restore the form data from the session. + * This should be called in your mount() method. + */ public function restore(): void { if (! $this->useStore() || ! $this->hasStore()) { @@ -18,6 +22,10 @@ public function restore(): void ); } + /** + * Stores the form data in the session. + * This should be called in your updated() method. + */ public function store(): void { if (! $this->useStore() || ! $this->storeWhen()) { @@ -30,6 +38,10 @@ public function store(): void session()->put($this->storeId(), serialize($this->storeWith())); } + /** + * Forget the form data from the session. + * This may be called in your clear() method. + */ public function forget(): void { session()->forget($this->storeId()); diff --git a/src/Views/Concerns/WithSeo.php b/src/Views/Concerns/WithSeo.php index 72817b1..1154d85 100644 --- a/src/Views/Concerns/WithSeo.php +++ b/src/Views/Concerns/WithSeo.php @@ -7,6 +7,15 @@ trait WithSeo { public function bootWithSeo(): void + { + if (! $this->shouldSetSeoMeta()) { + return; + } + + $this->setSeoMeta(); + } + + protected function setSeoMeta(): void { if (method_exists(static::class, 'getTitle')) { SEOMeta::setTitle($this->getTitle()); @@ -20,4 +29,9 @@ public function bootWithSeo(): void SEOMeta::setRobots($this->getRobots()); } } + + protected function shouldSetSeoMeta(): bool + { + return class_exists(SEOMeta::class); + } } diff --git a/src/WireUseServiceProvider.php b/src/WireUseServiceProvider.php index d264fc4..29cc347 100644 --- a/src/WireUseServiceProvider.php +++ b/src/WireUseServiceProvider.php @@ -52,7 +52,7 @@ protected function registerFeatures(): static protected function registerStructureDiscovery(): static { if (! InstalledVersions::isInstalled('spatie/php-structure-discoverer')) { - abort(500, 'The spatie/php-structure-discoverer package is required to use the Structure Discovery.'); + abort(500, 'The spatie/php-structure-discoverer package is required to use Structure Discovery.'); } $this->app->singleton(ComponentScout::class, fn () => new ComponentScout); @@ -64,7 +64,7 @@ protected function registerStructureDiscovery(): static protected function registerHtmlMixins(): static { if (! InstalledVersions::isInstalled('spatie/laravel-html')) { - abort(500, 'The spatie/laravel-html package is required to use the HTML mixins.'); + abort(500, 'The spatie/laravel-html package is required to use HTML mixins.'); } $mixins = [