Skip to content

Instantly share code, notes, and snippets.

@angelkurten
Last active July 25, 2016 14:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save angelkurten/8c288de5f511d965c27b to your computer and use it in GitHub Desktop.
Use Menus package Styde/html
<?php namespace App;
abstract class BaseMenu
{
protected $class = null;
/**
* @param null $class
*/
public function setClass($class)
{
$this->class = $class;
}
/**
* Specify Items Menu
* @return string
*/
abstract function items();
public function boot()
{
return \Menu::make($this->items(), $this->class);
}
}
{!! $principal->boot() !!}
<?php namespace Modules\Dashboard\Http\Controllers;
use Modules\Dashboard\Repositories\DashboardRepository;
use Pingpong\Modules\Routing\Controller;
use Modules\Dashboard\Menus\PrincipalMenu;
class FrontendController extends Controller {
/**
* @var DashboardRepository
*/
private $dashboard;
public function __construct(DashboardRepository $dashboard)
{
$this->dashboard = $dashboard;
}
public function index()
{
$data = $this->dashboard->all()[0];
$principal = new PrincipalMenu();
return view('dashboard::frontend', compact('data', 'principal'));
}
}
<?php namespace Modules\Dashboard\Menus;
use App\BaseMenu;
class PrincipalMenu extends BaseMenu
{
public function __construct()
{
$this->class = 'nav navbar-nav navbar-right nav-effect uppercase';
}
/**
* Specify Items Menu
* @return string
*/
public function items()
{
return [
'home' => [
'title' => trans('dashboard::menus.principal.home'),
'url' => '#home',
'data-scroll' => true
],
'about' => [
'title' => trans('dashboard::menus.principal.about'),
'url' => '#about',
'data-scroll' => true
],
'team' => [
'title' => trans('dashboard::menus.principal.team'),
'url' => '#team',
'data-scroll' => true
],
'services' => [
'title' => trans('dashboard::menus.principal.services'),
'url' => '#services',
'data-scroll' => true
],
'platform' => [
'title' => trans('dashboard::menus.principal.platform'),
'url' => '#',
'data-scroll' => true
],
'contact' => [
'title' => trans('dashboard::menus.principal.contact'),
'url' => '#contact',
'data-scroll' => true
],
'facebook' => [
'title' => 'facebook',
'url' => '#',
'icon' => true,
],
'twitter' => [
'title' => 'twitter',
'url' => '#',
'icon' => true,
],
'google' => [
'title' => 'google',
'url' => '#',
'icon' => true,
],
];
}
}
@sileence
Copy link

Hey, nice implementation, btw, read the documentation, the base component allows translation out of the box,you don't need to write:

'title' => trans(...)

@angelkurten
Copy link
Author

@sileence I work with modules and the package was not translations, so I had to use trans ()

@jorarmarfin
Copy link

As introducing an icon menu item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment