PHP code example of acr / menu

1. Go to this page and download the library: Download acr/menu library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

acr / menu example snippets

 
PHP
namespace App\Http\Middleware;

use Acr\Menu\Model\AcrUser;
use Closure;
use Auth;

class Admin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user_model = new AcrUser();
        $isAdmin    = $user_model->where('id', Auth::user()->id)->with([
            'roles' => function ($query) {
                $query->where('role_id', 1);
            }
        ])->first();
        // dd($isAdmin->roles->count());
        if ($isAdmin->roles->count() == 0 || $isAdmin->roles[0]->id != 1) {
            return redirect('/yetkisiz');
        }
        return $next($request);
    }
}

 
'admin'      => \App\Http\Middleware\Admin::class
 
PHP
 echo AcrMenu::acr_sol_menu(@$tab);