无论我做什么 crud middlware 总是被解雇。$crud
但是,只有在声明数组并且仅针对它包含的路由时才应该触发它。但是,并非每次都会触发。即使我说$crud = [];
但是,如果我声明['only' => ['route1', 'route2']]
,那么它会按预期工作。
<?php
class BaseController extends Controller
{
/**
* Routes which DO NOT load users notifications.
* @var Array Routes without notifications.
*/
public $notifications;
/**
* Routes which DONT require users account to be configured.
* @var Array Routes needing configuration.
*/
public $configured;
/**
* Routes which REQUIRE ownership of resource.
* @var Array CRUD routes.
*/
public $crud;
public function __construct()
{
$this->middleware('auth', ['except' => $this->routes]);
$this->middleware('configured', ['except' => $this->configured]);
$this->middleware('notifications', ['except' => $this->notifications]);
$this->middleware('crud', ['only' => $this->crud]);
}
}