mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-13 18:24:04 +00:00
finished
This commit is contained in:
parent
051a32575c
commit
b12c9ecb55
21 changed files with 750 additions and 86 deletions
40
src/SEOServiceProvider.php
Normal file
40
src/SEOServiceProvider.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ArchTech\SEO;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ImLiam\BladeHelper\Facades\BladeHelper;
|
||||
|
||||
class SEOServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton('seo', SEOManager::class);
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->loadViewsFrom(__DIR__ . '/../assets/views', 'seo');
|
||||
|
||||
$this->publishes([
|
||||
__DIR__ . '/../assets/views' => resource_path('views/vendor/seo'),
|
||||
], 'seo-views');
|
||||
|
||||
BladeHelper::directive('seo', function (...$args) {
|
||||
if (count($args) === 2) {
|
||||
return seo()->set($args[0], $args[1]);
|
||||
}
|
||||
|
||||
if (is_array($args[0])) {
|
||||
seo($args[0]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return seo()->get($args[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue