2016-03-16 103 views
2

你好,我是使用實施laravel 5.2密鑰驗證這個package使用API​​後衛Laravel 5.2

它給我一個錯誤

ErrorException in ApiGuardAuth.php line 14: 
Argument 1 passed to Chrisbjr\ApiGuard\ApiGuardAuth::__construct() must be an instance of Chrisbjr\ApiGuard\Contracts\Providers\Auth, null given, called in E:\xammp\htdocs\vox\didww\vendor\chrisbjr\api-guard\src\Providers\ApiGuardServiceProvider.php on line 49 and defined 

這裏是我的控制器

<?php 

namespace App\Http\Controllers; 
use Chrisbjr\ApiGuard\Models; 
use Chrisbjr\ApiGuard\Http\Controllers\ApiGuardController; 



class BooksController extends ApiGuardController 
{ 

    public function all() 
    { 
     return "die"; 
     $books = \App\User::all(); 

     return $this->response->withCollection($books, new BookTransformer); 
    } 

    public function show($id) 
    { 
     try { 

      $book = \App\User::findOrFail($id); 

      return $this->response->withItem($book, new BookTransformer); 

     } catch (ModelNotFoundException $e) { 

      return $this->response->errorNotFound(); 

     } 
    } 

} 

我也更新了app.php和kernal.php 有什麼建議嗎?

P.S對不起我的英文不好

+1

我也跟着這個[link](https://blog.muya.co.ke/api-guard-laravel-5-2/) –

回答

3

錯誤是3.0.3和3.1.0嘗試降級之間引入到3.0.3可能會有所幫助。

你也可以嘗試加入此塊到app/config/apiguard.php文件更新最新的封裝API-gaurd

0

修正這個對我的身材。

'providers'   => [ 
    'auth' => Chrisbjr\ApiGuard\Providers\Auth\Illuminate::class 
],