Container for Laravel for collecting data for views
This package creates a singleton into the Service container. In this site container you can put from your whole application items., (*1)
At the end the container will be added as a shared view variable., (*2)
Install it with composer, (*3)
composer require laravel-admin/site
Add the Service Provider to your config/app.php, (*4)
LaravelAdmin\Site\SiteServiceProvider::class,
The package has a config, with a basic structure. Publish this config to define your defaults., (*5)
artisan vendor:publish --tag="site"
The container is available in the whole application with:, (*6)
app('site')
app('site')->set('title', 'My website title');
The container is compatible with the dotted array notation, like config, (*7)
app('site')->set('seo.title', 'This is my SEO improved title');
app('site')->get('title');
app('site')->get('seo.title');
Imagine you have a model with some default content attributes, like title, description and content. With one command you can fill all items in the container., (*8)
app('site')->model($post);
The container will be available in all your views as the $site variable. Use it as follow:, (*9)
{{ $site->get('title') }}