Skip to content

Instantly share code, notes, and snippets.

@harini-ua
Created June 20, 2017 11:54
Show Gist options
  • Save harini-ua/9a383e0ae3891bc4012111c11134ca93 to your computer and use it in GitHub Desktop.
Save harini-ua/9a383e0ae3891bc4012111c11134ca93 to your computer and use it in GitHub Desktop.
<?php
// FooterComposer.php
namespace App\Http\ViewComposers;
use App\Repositories\StaticPageRepository;
use Illuminate\View\View;
/**
* Class FooterComposer
* @package App\Http\ViewComposers
*/
class FooterComposer
{
/** @var StaticPageRepository */
protected $staticPageRepository;
/**
* @param StaticPageRepository $staticPageRepository
*/
public function __construct(StaticPageRepository $staticPageRepository)
{
$this->staticPageRepository = $staticPageRepository;
}
/**
* Bind data to the view.
*
* @param View $view
*
* @return void
*/
public function compose(View $view)
{
$view->with('pages', $this->staticPageRepository->urlList());
}
}
// FooterServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Http\ViewComposers\FooterComposer;
/**
* Class FooterServiceProvider
* @package App\Providers
*/
class FooterServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer(
'frontend/partials/_footer', FooterComposer::class
);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
// config/app.php
App\Providers\FooterServiceProvider::class,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment