1

私が何をしても、ミドルウェアは常に解雇されます。$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]);
    }
}
4

1 に答える 1