[转] 404 页面设计 404 Page Inspiration

https://medium.com/muzli-design-inspiration/404-page-inspiration-de4ec8618693#.fhueqx8rz

 

404 Page Inspiration

via Muzli design inspiration

Awesome Kit “404” illustration by Awesomed

404 by Arthur MB
Missing File by Zach Graham for Dropbox

404 — funky monkey by Tony Babel
Tubik Studio | Page 404 by Ernest Asanov for Tubik Studio
404 Page by Timothy J. Reynolds for Twitch
Dropbox Community : 404 by UENO
404 — Uh oh! by Andrew Colin Beck
404 — OMG! by Andrew Colin Beck
No Bananas here by John Torres ♖♜ for Nutanix
V2 by Halvor Nordrum
404 Page Not Found! by Adheedhan Ravikumar
404 error by Aleksandr Romanukha
#3 404 Page by Denis Abdullin
404 by Jeff Lupinski
404 bulb by Eddie Lobanovskiy
404 error page. Atech psd template by Olia Gozha
Error, Location not found ! by Ghani Pradita
404 by Olga Baydalinova
404 page by Viktor Kern
Daily UI 008: 404 Page by Abhas Sinha
404 by Oleg Frolov
404 page with an inspiring quote by Andrew
UI challenge — 404 page #008 +PSD by This Optimism
404 Get Lost by Anthony Lagoon for Underbelly
404 by Seán Halpin

Oops! by Airbnb
Foodly 404 by Olia Gozha for Congruity Hub
404 concept by Daniel Haire for Yik Yak
Page Cannot Be Found by Lumen Bigott for Eventbrite
Page 404 by Ilja Miskov for Peppers
Heyllow New Website by Valentine Boyev for Heyllow
4 oh.. 4 by Justas Galaburda for Studio4 | Creative

404 Page by Frank Rodriguez
Daily UI — 404 Error Page! by Victor Belinatti
Day 8: 404 by Julius Koroll
404 Page by Ryan Duffy
Daily UI #24 — Error 404 by Patryk Wąsik for Symu.co

#dailyui by Pete Lacey
Daily UI: Day 8–404 Page by matt rossi
100 Days Sketch UI Contest #day008–404 Error Page by Paweł Łuczak
Daily UI Day #8 by Jonas Verheijden
Day 021 — Error 404 by HEZY
404 page by Roman Menshikov
Daily UI 404 Error by Susana Gonzalez
404 Page by Patryk Zabielski
DailyUI 008: 404 page by Frexy
404 by Danny Groenen
404 page by Roman Menshikov
404 Error Daily UI #008 by Vania Vega

So much more amazing content…

Join over 60,000 others who enjoy Muzli for Chrome.
Muzli is a goldmine of inspiring, beautiful & fresh content, stunningly delivered every time you open up a new tab.

1,328 total views, no views today

[转] Mobile Navigation Inspiration 移动应用的导航设计

惊艳。

转自 https://medium.com/muzli-design-inspiration/mobile-navigation-inspiration-f2a33bcbc9cb#.ikc6l5uky

via Muzli design inspiration

Safari view by Gleb Kuznetsov

Travel Blog App Concept by Anatoliy Nesterov for Yalantis

Tab Bar Animation by Vitaly Rubtsov for Yalantis
Dashboard and Menu by Megan Fox for Notch Interactive

App Navigation by Ramotion

Bottom Nav Experiments by Vitaly Rubtsov for Yalantis
Evernote Skitch iOS by Jesse Guerrero for Evernote Design

Navigation Concept by Steffen Nørgaard Andersen for Magnetix

Shopping List by by Hila Peleg

Trello Navigation by Aurélien Salomon

Navigation by Cuberto

iPad Mini Template (Preview) by Creativedash

UI Navigation Concept by Ludmila Shevchenko for Tubik Studio

Large Screen Navigation by Ramotion

App Navigation Pulldown by ⋈ Sam Thibault ⋈ for Handsome

App Circle Navigation by ⋈ Sam Thibault ⋈ for Handsome

Look flow by Aleksandr Larionov for LUFT

Healthy Choice by Dejan Markovic

Navigation at the bottom by Aurélien Salomon

pSettings fun navigation by Aurélien Salomon

So much more amazing content…

Join over 60,000 others who enjoy Muzli for Chrome.
Muzli is a goldmine of inspiring, beautiful & fresh content, stunningly delivered every time you open up a new tab.

922 total views, no views today

[转] viewport的研究

英文:http://www.quirksmode.org/mobile/viewports.html

中文: http://weizhifeng.net/viewports.html

 

 

934 total views, 1 views today

[转]理发店官网

转一个逼格满满的主页

http://offandon.me/

900 total views, no views today

[转] 糙男手写权限管理系统 laravel ACL

没有想像的复杂。

http://heera.it/laravel-5-0-acl-using-middleware#.Vqtg7bB96SM

 

Well, actually building an ACL (Access Control Layer) in Laravel is really very easy than using a third party package and I always prefer my own implementation. In Laravel - 4x we’ve used Route Filter mechanism to build an ACL but in Laravel - 5.0 now we have Middleware instead of Filter and it’s much better, IMO.

The idea behind the ACL is that, we want to protect our routes using user roles and permissions and in this case the underlying mechanism is quite same in both versions but only difference is that, in Laravel - 5.0 theMiddleware is the layer (for filtering) between our routes and the application, while in Laravel - 4x the Route Filter was used for filtering the requests before the user gets into the application. In this article, I’ll show how it’s easily possible to implement an ACL from the scratch using Middleware.

It’s possible to implement ACL in different ways but this is what I’ve used in Laravel - 4x and also in Laravel - 5.0 and this could be enhanced or improved but approach may varies but the idea is same, filtering user requests before entering into the application layer.
TO IMPLEMENT THIS, WE NEED 4 TABLES:
  • 1. users
  • 2. roles
  • 3. permissions
  • 4. permission_role (Pivot Table)
DATABASE MIGRATION FOR users TABLE:
01 <?php
02
03 use Illuminate\Database\Migrations\Migration;
04 use Illuminate\Database\Schema\Blueprint;
05
06 class CreateUsersTable extends Migration {
07
08     /**
09      * Run the migrations.
10      *
11      * @return void
12      */
13     public function up()
14     {
15         Schema::create('users', function(Blueprint $table)
16         {
17             $table->increments('id')->unsigned();
18             $table->integer('role_id')->unsigned();
19             $table->string('email')->unique();
20             $table->string('password');
21             $table->string('first_name');
22             $table->string('last_name');
23             $table->rememberToken();
24             $table->timestamps();
25             $table->softDeletes();
26         });
27     }
28
29     /**
30      * Reverse the migrations.
31      *
32      * @return void
33      */
34     public function down()
35     {
36         Schema::drop('users');
37     }
38 }
DATABASE MIGRATION FOR roles TABLE:
01 <?php
02
03 use Illuminate\Database\Schema\Blueprint;
04 use Illuminate\Database\Migrations\Migration;
05
06 class CreateRolesTable extends Migration {
07
08    /**
09     * Run the migrations.
10     *
11     * @return void
12     */
13    public function up()
14    {
15       Schema::create('roles', function(Blueprint $table)
16       {
17          $table->increments('id');
18          $table->string('role_title');
19          $table->string('role_slug');
20       });
21    }
22
23    /**
24     * Reverse the migrations.
25     *
26     * @return void
27     */
28    public function down()
29    {
30       Schema::drop('roles');
31    }
32
33 }
DATABASE MIGRATION FOR permissions TABLE:
01 <?php
02
03 use Illuminate\Database\Schema\Blueprint;
04 use Illuminate\Database\Migrations\Migration;
05
06 class CreatePermissionsTable extends Migration {
07
08    /**
09     * Run the migrations.
10     *
11     * @return void
12     */
13    public function up()
14    {
15       Schema::create('permissions', function(Blueprint $table)
16       {
17          $table->increments('id');
18          $table->string('permission_title');
19          $table->string('permission_slug');
20          $table->string('permission_description')->nullable();
21       });
22    }
23
24    /**
25     * Reverse the migrations.
26     *
27     * @return void
28     */
29    public function down()
30    {
31       Schema::drop('permissions');
32    }
33
34 }
DATABASE MIGRATION FOR permission_role TABLE:
01 <?php
02
03 use Illuminate\Database\Schema\Blueprint;
04 use Illuminate\Database\Migrations\Migration;
05
06 class CreatePermissionRoleTable extends Migration {
07
08    /**
09     * Run the migrations.
10     *
11     * @return void
12     */
13    public function up()
14    {
15       Schema::create('permission_role', function(Blueprint $table)
16       {
17          $table->increments('id');
18          $table->integer('permission_id');
19          $table->integer('role_id');
20       });
21    }
22
23    /**
24     * Reverse the migrations.
25     *
26     * @return void
27     */
28    public function down()
29    {
30       Schema::drop('permission_role');
31    }
32
33 }

These tables are required to build the ACL fields could be changed (add/remove) but to build the relationship between tables we need foreign keys and we can’t remove those fields such as role_id in users table and the pivot table is also necessary as it is.

Now, we need to create the middleware class to check the user permissions and we can create it using php artisan make:middleware CheckPermission from command line/terminal. This will create a skeleton of a middlewareclass in app/Http/Middleware directory as CheckPermission.php and now we need to edit that class as given below:

01 <?php namespace App\Http\Middleware;
02
03 use Closure;
04 use Illuminate\Contracts\Routing\Middleware;
05
06 class CheckPermission implements Middleware {
07
08    /**
09     * Handle an incoming request.
10     *
11     * @param  \Illuminate\Http\Request  $request
12     * @param  \Closure  $next
13     * @return mixed
14     */
15    public function handle($request, Closure $next)
16    {
17       if($this->userHasAccessTo($request)) {
18
19          view()->share('currentUser', $request->user());
20          
21          return $next($request);
22       }
23
24       return redirect()->route('home');
25    }
26
27    /*
28    |--------------------------------------------------------------------------
29    | Additional helper methods for the handle method
30    |--------------------------------------------------------------------------
31    */
32
33    /**
34     * Checks if user has access to this requested route
35     *
36     * @param  \Illuminate\Http\Request  $request
37     * @return Boolean true if has permission otherwise false
38     */
39    protected function userHasAccessTo($request)
40    {
41       return $this->hasPermission($request);
42    }
43
44    /**
45     * hasPermission Check if user has requested route permimssion
46     *
47     * @param  \Illuminate\Http\Request $request
48     * @return Boolean true if has permission otherwise false
49     */
50    protected function hasPermission($request)
51    {
52       $required = $this->requiredPermission($request);
53
54       return !$this->forbiddenRoute($request) && $request->user()->can($required);
55    }
56
57    /**
58     * Extract required permission from requested route
59     *
60     * @param  \Illuminate\Http\Request  $request
61     * @return String permission_slug connected to the Route
62     */
63    protected function requiredPermission($request)
64    {
65       $action = $request->route()->getAction();
66
67       return isset($action['permission']) ? explode('|', $action['permission']) : null;
68    }
69
70    /**
71     * Check if current route is hidden to current user role
72     *
73     * @param  \Illuminate\Http\Request $request
74     * @return Boolean true/false
75     */
76    protected function forbiddenRoute($request)
77    {
78       $action = $request->route()->getAction();
79
80       if(isset($action['except'])) {
81          
82          return $action['except'] == $request->user()->role->role_slug;
83       }
84
85       return false;
86    }
87 }

Now, we need to create other classes (Eloquent Model) in app/DB directory. Here, in Laravel - 5.0 the models directory is not available and by default the app directory contains the Eloquent model classes such as Userbut I’ve created the DB directory to house all of my Eloquent/Fluent classes but it’s not mandatory. Anyways, let’s create those classes (User, Role and Permission) now in app/DB or just in app (The full path of User class must be given in the config/Auth.php file).

01 <?php namespace App\DB\User;
02
03 use Illuminate\Auth\Authenticatable;
04 use Illuminate\Database\Eloquent\Model;
05 use Illuminate\Auth\Passwords\CanResetPassword;
06 use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
07 use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
08 use App\Http\Requests\Auth\RegisterRequest;
09 use App\DB\User\Traits\UserACL;
10 use App\DB\User\Traits\UserAccessors;
11 use App\DB\User\Traits\UserQueryScopes;
12 use App\DB\User\Traits\UserRelationShips;
13
14 class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
15
16    use Authenticatable, CanResetPassword;
17
18    /**
19     * Application's Traits (Separation of various types of methods)
20     */
21    use UserACL, UserRelationShips;
22 }

The traits are used to separate the code in User class to keep the code clean and easily maintainable, (app/DB/User/Traits/UserACL.php trait):

001 <?php namespace App\DB\User\Traits;
002
003 trait UserACL {
004    
005    /**
006     * can Checks a Permission
007     *
008     * @param  String $perm Name of a permission
009     * @return Boolean true if has permission, otherwise false
010     */
011    public function can($perm = null)
012    {
013       if($perm) {
014
015          return $this->checkPermission($this->getArray($perm));  
016       }
017
018       return false;
019    }
020
021    /**
022     * Make string to array if already not
023     *
024     * @param  Mixed $perm String/Array
025     * @return Array
026     */
027    protected function getArray($perm)
028    {
029       return is_array($perm) ? $perm : explode('|', $perm);
030    }
031
032    /**
033     * Check if the permission matches with any permission user has
034     *
035     * @param  Array $perm Name of a permission (one or more separated with |)
036     * @return Boolean true if permission exists, otherwise false
037     */
038    protected function checkPermission(Array $permArray = [])
039    {
040       $perms = $this->role->permissions->fetch('permission_slug');
041       
042       $perms = array_map('strtolower', $perms->toArray());
043
044       return count(array_intersect($perms, $permArray));
045    }
046
047    /**
048     * hasPermission Checks if has a Permission (Same as 'can')
049     *
050     * @param  String $perm [Name of a permission
051     * @return Boolean true if has permission, otherwise false
052     */
053    public function hasPermission($perm = null)
054    {
055       return $this->can($perm);
056    }
057
058    /**
059     * Checks if has a role
060     *
061     * @param  String $perm [Name of a permission
062     * @return Boolean true if has permission, otherwise false
063     */
064    public function hasRole($role = null)
065    {
066       if(is_null($role)) return false;
067       
068       return strtolower($this->role->role_slug) == strtolower($role);
069    }
070
071    /**
072     * Check if user has given role
073     *
074     * @param  String $role role_slug
075     * @return Boolean TRUE or FALSE
076     */
077    public function is($role)
078    {
079       return $this->role->role_slug == $role;
080    }
081
082    /**
083     * Check if user has permission to a route
084     *
085     * @param  String $routeName
086     * @return Boolean true/false
087     */
088    public function hasRoute($routeName)
089    {
090       $route = app('router')->getRoutes()->getByName($routeName);
091
092       if($route) {
093
094          $action = $route->getAction();
095          
096          if(isset($action['permission'])) {
097             
098             $array = explode('|', $action['permission']);
099
100             return $this->checkPermission($array);
101          }
102       }
103
104       return false;
105    }
106
107    /**
108     * Check if a top level menu is visible to user
109     *
110     * @param  String $perm
111     * @return Boolean true/false
112     */
113    public function canSeeMenuItem($perm)
114    {
115       return $this->can($perm) || $this->hasAnylike($perm);
116    }
117    
118    /**
119     * Checks if user has any permission in this group
120     *
121     * @param  String $perm Required Permission
122     * @param  Array $perms User's Permissions
123     * @return Boolean true/false
124     */
125    protected function hasAnylike($perm)
126    {
127       $parts = explode('_', $perm);
128       
129       $requiredPerm = array_pop($parts);
130
131       $perms = $this->role->permissions->fetch('permission_slug');
132
133       foreach ($perms as $perm)
134       {
135          if(ends_with($perm, $requiredPerm)) return true;
136       }
137
138       return false;
139    }
140 }

The app/DB/User/Traits/UserRelationShips.php trait (for relationship methods):

01 <?php namespace App\DB\User\Traits;
02
03 trait UserRelationShips {
04
05    /**
06     * role() one-to-one relationship method
07     *
08     * @return QueryBuilder
09     */
10    public function role()
11    {
12       return $this->belongsTo('App\DB\Role');
13    }
14 }

The Role class (app/DB/Role.php):

01 <?php namespace App\DB;
02
03 use Illuminate\Database\Eloquent\Model;
04
05 class Role extends Model {
06
07     /**
08     * users() one-to-many relationship method
09     *
10     * @return QueryBuilder
11     */
12    public function users()
13    {
14       return $this->hasMany('App\DB\User\User');
15    }
16
17    /**
18     * permissions() many-to-many relationship method
19     *
20     * @return QueryBuilder
21     */
22    public function permissions()
23    {
24       return $this->belongsToMany('App\DB\Permission');
25    }
26 }

The Permission class (app/DB/Permission.php):

01 <?php namespace App\DB;
02
03 use Illuminate\Database\Eloquent\Model;
04
05 class Permission extends Model {
06
07    /**
08     * roles() many-to-many relationship method
09     *
10     * @return QueryBuilder
11     */
12    public function roles()
13    {
14       return $this->belongsToMany('App\DB\Role');
15    }
16 }

Now, before we can use our Middleware in any route declaration, we need to add it it in the app/Http/Kernel.phpfile and by default, there are already other middlewares added in that file by Laravel in the $routeMiddlewarearray and it looks like this:

01 /**
02  * The application's route middleware.
03  *
04  * @var array
05  */
06 protected $routeMiddleware = [
07     'auth' => 'App\Http\Middleware\Authenticate',
08     'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
09     'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
10 ];

We’ll just add our middleware at the end of this array like this:

1 'acl' => 'App\Http\Middleware\CheckPermission',

The acl is the alias which we’ll use in our routes when declaring the routes for limited access, for example take a look at this app/Http/routes.php file:

01 // Home Page URI (not protected)
02 $router->get('/', ['uses' => 'HomeController@index', 'as' => 'home']);
03
04 // Protected Routes by auth and acl middleware
05 $router->group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['auth', 'acl']],function() use ($router)
06 {
07    $router->get('dashboard', [
08       'uses' => 'DashboardController@index',
09       'as' => 'dashboard',
10       'permission' => 'manage_own_dashboard',
11       'menuItem' => ['icon' => 'fa fa-dashboard', 'title' => 'Dashboard']
12    ]);
13
14     // Group: Users
15     $router->group(['prefix' => 'users', 'namespace' => 'User'], function() use ($router)
16     {
17         $router->get('/{role?}', [
18             'uses' => 'UserController@index',
19             'as' => 'admin.users',
20             'permission' => 'view_user',
21             'menuItem' => ['icon' => 'clip-users', 'title' => 'Manage Users']
22         ])->where('role', '[a-zA-Z]+');
23
24         $router->get('view/{id}', [
25             'uses' => 'UserController@viewUserProfile',
26             'as' => 'admin.user.view',
27             'permission' => 'view_user'
28         ]);
29     });
30 });

In this file, all of our routes are protected and requires the user to stay logged in (auth is used to check whether the user is logged in or not, available by default in Laravel) and the acl will check if the user has a given permission or not, for example, the dashboard url/route requires the permission manage_own_dashboard because it has'permission' => 'manage_own_dashboard' and in our middleware we’ll check if the route has the key permission in it’s action and if the value of permission key (which is a permission) is available in the currently logged in users role permissions list then we’ll allow the user to access the application, otherwise we’ll disallow the user access.

On the time, when this article is being written, the Laravel-5.0 framework isn’t released and after the final release, things may change so please make sure you check the updates on Laravel websiteand hoping, in the first week of January’15, Laravel-5.0 will be released.
HOW IT WORKS?

Actually, this is just a demonstration of only the ACL but I didn’t provide any code which provides an user interface that let’s the admin a way to create user roles by attaching the permissions but only the core idea to implement the ACL in the application.

So, a brief idea is that, each user will be assigned a role when user account is created from the front-end or by the admin (a default role could be set from the back-end) and the roles will be created by admin (super user) from the back-end and permissions will be attached to each roles. So, a role for example Moderator which could have a permission as Suspend User (permission title) and suspend_user (permission_slug) so we can attachsuspend_user in a Route using something like this:

1 $router->get('user/suspend/{id}', [
2     uses' => 'UserController@closeUserAccount',
3     'as' => 'admin.user.suspend',
4     'permission' => 'suspend_user',
5     'middleware' => ['acl']
6 ]);

So, this route requires the permission suspend_user and in the acl middleware we can check the user’s permission and can protect the route if the user doesn’t has that permission. That’s it.

In this article, I tried discussed how to organize the tables and classes and how to filter the requests using middleware and what classes could be required but not full implementation of a fully functional system, it just gives an abstract idea to create an ACL functionality using Laravel - 5 Middleware from the scratch (without using any third party package).

Since the Laravel-5.0 is still under development, so I didn’t provide the fully functional code here and once the framework is released, then I’ll write another post, maybe in two parts as a series with fully functional code for building an ACL from the scratch, but for now, that’s all. Thank you.

UPDATE:

In my code example, I’ve used menuItem as a key in route declaration. This key is used to build a dynamic menu and to build the menu I’ve created a class/library which is located at app/Libs/Navigation folder of my project. The menu builder class is given below:

001 <?php namespace App\Libs\Navigation;
002
003 use Illuminate\Support\Arr;
004 use Illuminate\Http\Request;
005 use Illuminate\Routing\Router;
006
007 class Builder {
008
009    private $menuItems = [];
010    private $routes = NULL;
011    private $user = NULL;
012
013    public function __construct(Arr $arr, Request $request, Router $router)
014    {
015       $this->arr = $arr;
016       $this->request = $request;
017       $this->user = $request->user();
018       $this->router = $router;
019       $this->routes = $router->getRoutes();
020    }
021    
022    /**
023     * Extract all top level menu items from routes
024     *
025     * @return Array A multi-dementional array
026     */
027    public function build()
028    {
029       foreach ($this->routes->getIterator() as $it) {
030
031          $action = $it->getAction();
032          
033          if(!$this->forbidden($action) && $item = $this->arr->get($action, 'menuItem')) {
034          
035             $routeName = $this->arr->get($action, 'as');
036
037             $this->menuItems[$routeName] = array('icon' => @$item['icon'], 'title' => @$item['title']);
038          }
039       }
040
041       return $this;
042    }
043
044    /**
045     * Check if current route is hidden to current user role
046     *
047     * @param  \Illuminate\Http\Request $request
048     * @return Boolean true/false
049     */
050    protected function forbidden($action)
051    {
052       if(isset($action['except']))
053       {
054          return $action['except'] == $this->user->roles->fetch('role_slug');
055       }
056
057       return false;
058    }
059
060    /**
061     * Render all HTML li tags
062     *
063     * @param  Array $menuItems
064     * @param  string $itemView View name to generate a single li
065     * @return HTML li items as String
066     */
067    public function render($itemView = 'admin.layouts.partials.content.navLiTemplate')
068    {
069       $listElements = [];
070
071       foreach ($this->menuItems as $routeName => $itemArray) {
072          
073          $listElements[] = $this->getListItem($routeName, $itemArray);
074       }
075
076       return join($listElements, '');
077    }
078
079    /**
080     * Build a menu item by checking the permissions.
081     *
082     * @param  String $routeName Name of the route to generate link
083     * @param  Array $itemArray List of route's menuItem array
084     * @return HTML li Element as menu item
085     */
086    protected function getListItem($routeName, $itemArray)
087    {
088       $action = $this->routes->getByName($routeName)->getAction();
089
090       $permission = $this->arr->get($action, 'permission');
091
092       if((!empty($permission) && $this->user->canSeeMenuItem($permission)) ||empty($permission))
093       {
094
095          $except = $this->arr->get($action, 'except');
096
097          if((!isset($except) || (isset($except) && !count($except))) || (isset($except) && !$this->user->is($except))) {
098             
099             $data = [
100                'link' => route($routeName),
101                'active' => $this->isActive($routeName),
102                'title' => $this->getTitle($itemArray['title']),
103                'icon' => $itemArray['icon'],
104                'id' => str_replace(' ', '-', strtolower($itemArray['title']))
105             ];
106             
107             return view('admin.layouts.partials.content.navLiTemplate', $data);
108          }
109       }
110    }
111
112    /**
113     * Mark active menu item
114     *
115     * @param  String $routeName Route Name
116     * @return HTML Attribute or NULL
117     */
118    protected function isActive($routeName)
119    {
120       return $this->router->getCurrentRoute()->getName() == $routeName ? 'active' : NULL;
121    }
122 }

Further, to invoke the menu builder class I’ve created a helper function in a helper file which isapp/Helpers/fucntions.php and the function is given below:

1 /**
2  * Build the top level navigation
3  *
4  * @return HTML list items (li) as string
5  */
6 function renderMenu()
7 {
8    return app('App\Libs\Navigation\Builder')->build()->render();
9 }

Finally, I’ve called the function from my view where I wanted to show the menu and the view is a partial of my admin layout which contains following code:

1 <!-- admin/layouts/partials/nav.blade.php-->
2 <!-- start: MAIN NAVIGATION MENU -->
3 <ul class="main-navigation-menu">
4    {!! renderMenu() !!}
5 </ul>
6 <!-- end: MAIN NAVIGATION MENU -->

Stay in touch, full (improved code) will be uploaded on github later.

 

780 total views, 1 views today