php – Laravel 5 Class admin不存在

前端之家收集整理的这篇文章主要介绍了php – Laravel 5 Class admin不存在前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有了Laravel 5和这个管理类的问题,问题是所有东西都在localhost上工作,现在我在服务器上部署了它(大量的修复但没有触及它)它不起作用.

当我转到’/ moderate’页面时出现错误,该页面应该只有管理员才能看到.

错误

in Container.PHP line 776
at ReflectionClass->__construct('admin') in Container.PHP line 776
at Container->build('admin',array()) in Container.PHP line 656
at Container->make('admin',array()) in Application.PHP line 572
at Application->make('admin') in Pipeline.PHP line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.PHP line 47
at Authenticate->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure),object(Request)) in Pipeline.PHP line 101
at Pipeline->then(object(Closure)) in Router.PHP line 690
at Router->runRouteWithinStack(object(Route),object(Request)) in Router.PHP line 660
at Router->dispatchToRoute(object(Request)) in Router.PHP line 618
at Router->dispatch(object(Request)) in Kernel.PHP line 157
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure),object(Request)) in Pipeline.PHP line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.PHP line 43
at VerifyCsrfToken->handle(object(Request),object(Closure)) in VerifyCsrfToken.PHP line 17
at VerifyCsrfToken->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.PHP line 55
at ShareErrorsFromSession->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.PHP line 62
at StartSession->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.PHP line 36
at AddQueuedCookiesToResponse->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.PHP line 40
at EncryptCookies->handle(object(Request),object(Closure)) in Pipeline.PHP line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.PHP line 42
at CheckForMaintenanceMode->handle(object(Request),object(Request)) in Pipeline.PHP line 101
at Pipeline->then(object(Closure)) in Kernel.PHP line 108
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.PHP line 83
at Kernel->handle(object(Request)) in index.PHP line 53

AdminController位置(App / Http / Controllers /):

<?PHP namespace App\Http\Controllers;

use App\Post;
use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

class AdminController extends Controller {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $posts = Post::oldest()->where('status','=','0')->get();
        return view('admin.index',compact('posts'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function trash()
    {
        $posts = Post::oldest()->where('status','2')->get();
        return view('admin.trash',compact('posts'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function changeStatus($id,$status)
    {
        $post = Post::findOrFail($id);

        if($post->status != $status){
            $post->status = $status;
            $post->save();
        }

        return redirect('/moderate');
    }


}

路线:

// Admin only

Route::group(['middleware' => ['auth','admin']],function()
{
    Route::get('/moderate','AdminController@index');
    Route::get('/posts/{id}/status/{status}','AdminController@changeStatus');
    Route::get('/trash','AdminController@trash');
});
固定!

忘了同步Kernel.PHP

protected $routeMiddleware = [
        'auth' => 'App\Http\Middleware\Authenticate','auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth','guest' => 'App\Http\Middleware\RedirectIfAuthenticated',// This was missing
        'admin' => 'App\Http\Middleware\VerifyAdmin',];
原文链接:https://www.f2er.com/laravel/137817.html

猜你在找的Laravel相关文章