我正在使用spatie/laravel-permission来获取角色和权限。我正在尝试创建一个用于添加权限的界面。
PermissionController
<?php
namespace App\Http\Controllers;
use Spatie\Permission\Models\Permission;
use Illuminate\Http\Request;
use App\Http\Requests;
class PermissionController extends Controller
{
public function index()
{
$permissions = Permission::all();
return view('permissions.index', compact('permissions'));
}
public function create()
{
return view('permissions.create');
}
}
视图\权限\索引
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<ul class="fa-ul">
@foreach($permissions as $permission)
<li>{{ $permission->name }}</li>
@endforeach
<li><a href="{{ action('PermissionController@create') }}">Add Permission</a></li>
</ul>
</div>
</div>
@endsection
routes.php文件
Route::group(['middleware' => 'web'], function() {
Route::auth();
Route::resource('permission', 'PermissionController');
});
我可以加载/permission/
并列出所有权限,但是/permission/create
会返回以下错误/堆栈
FatalErrorException in AliasLoader.php line 63:
Maximum function nesting level of '100' reached, aborting!
in AliasLoader.php line 63
at FatalErrorException->__construct() in HandleExceptions.php line 133
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at spl_autoload_call() in ClassLoader.php line 22
in ClassLoader.php line 412
at Composer\Autoload\includeFile() in ClassLoader.php line 301
at ClassLoader->loadClass() in ClassLoader.php line 0
at spl_autoload_call() in ClassLoader.php line 12
in ClassLoader.php line 412
at Composer\Autoload\includeFile() in ClassLoader.php line 301
at ClassLoader->loadClass() in ConnectionFactory.php line 0
at spl_autoload_call() in ConnectionFactory.php line 220
at ConnectionFactory->createConnection() in ConnectionFactory.php line 64
at ConnectionFactory->createSingleConnection() in ConnectionFactory.php line 49
at ConnectionFactory->make() in DatabaseManager.php line 176
at DatabaseManager->makeConnection() in DatabaseManager.php line 68
at DatabaseManager->connection() in Model.php line 3280
at Model::resolveConnection() in Model.php line 3246
at Model->getConnection() in Model.php line 1873
at Model->newBaseQueryBuilder() in Model.php line 1846
at Model->newQueryWithoutScopes() in Model.php line 1816
at Model->newQuery() in EloquentUserProvider.php line 47
at EloquentUserProvider->retrieveById() in SessionGuard.php line 132
at SessionGuard->user() in GuardHelpers.php line 33
at SessionGuard->check() in GuardHelpers.php line 43
at SessionGuard->guest() in AuthManager.php line 282
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php:282}() in AuthManager.php line 282
at AuthManager->__call() in Facade.php line 215
at AuthManager->guest() in Facade.php line 215
at Facade::__callStatic() in d22449aa786380f3e4e16d4ff246527718a12265.php line 44
at Auth::guest() in d22449aa786380f3e4e16d4ff246527718a12265.php line 44
in PhpEngine.php line 42
at PhpEngine->evaluatePath() in CompilerEngine.php line 59
at CompilerEngine->get() in View.php line 147
at View->getContents() in View.php line 118
at View->renderContents() in View.php line 83
at View->render() in 4b8bfd68b9f2eba6cfd1c514c2e6470007e7477b.php line 26
in PhpEngine.php line 42
at PhpEngine->evaluatePath() in CompilerEngine.php line 59
at CompilerEngine->get() in View.php line 147
at View->getContents() in View.php line 118
at View->renderContents() in View.php line 83
at View->render() in Response.php line 53
at Response->setContent() in Response.php line 199
at Response->__construct() in Router.php line 1087
at Router->prepareResponse() in ControllerDispatcher.php line 95
at ControllerDispatcher->Illuminate\Routing\{closure}() in Pipeline.php line 52
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:52}() in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:103}() in Pipeline.php line 103
at Pipeline->then() in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack() in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch() in Route.php line 174
at Route->runController() in Route.php line 140
at Route->run() in Router.php line 724
at Router->Illuminate\Routing\{closure}() in Pipeline.php line 52
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:52}() in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}() in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in StartSession.php line 62
at StartSession->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in EncryptCookies.php line 59
at EncryptCookies->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:103}() in Pipeline.php line 103
at Pipeline->then() in Router.php line 726
at Router->runRouteWithinStack() in Router.php line 699
at Router->dispatchToRoute() in Router.php line 675
at Router->dispatch() in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}() in Pipeline.php line 52
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:52}() in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}() in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle() in Pipeline.php line 124
at call_user_func_array:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:124}() in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}() in Pipeline.php line 32
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:32}() in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}() in Pipeline.php line 103
at call_user_func:{E:\Development\Web\wamp\www\iqam\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:103}() in Pipeline.php line 103
at Pipeline->then() in Kernel.php line 132
at Kernel->sendRequestThroughRouter() in Kernel.php line 99
at Kernel->handle() in index.php line 54
in server.php line 21
at {main}() in server.php line 0