我在路由时遇到未经授权的操作错误:列表?

时间:2017-08-06 16:14:36

标签: php laravel frameworks console

这里不多说,除了我感到困惑?有帮助吗?无法找到答案!

如果您愿意,我会提供一些额外的背景信息;只是不知道从哪里开始。

Unauthorized action

这是我的auth.php。客户守卫是定制的:

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users'
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],

    'customers' => [
        'driver' => 'session',
        'provider' => 'customers',
    ],
],

这是我的CustomersController,里面只有索引功能。删除或添加构造没有区别:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;

class CustomersController extends Controller
{
/*public function __construct()
{
    $this->middleware('auth.customers');
}*/

public function index()
{
    return view('customers');
}
}

型号:

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

class Customers extends Model implements AuthenticatableContract
{
use Authenticatable;

protected $guard = 'customers';

/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'customers';

/**
 * The attributes excluded from the model's JSON form.
 *
 * @var array
 */
protected $hidden = ['password'];

/**
 * The attributes that are mass assignable.
 *
 * @var array $fillable
 */
protected $fillable = [
    'id',
    'username',
    'email',
    'password',
    'remember_token'
];
}

和路线:

Route::get('/customers', 'CustomersController@index');

0 个答案:

没有答案