【发布时间】:2021-06-28 02:02:23
【问题描述】:
我正在维护一些我的大学编写的 Laravel 6 代码。
我发现他们覆盖了控制器中的 callAction 方法并在其中初始化了一些变量。但我在 Laravel 3-8 文档中找不到 callAction 方法。
在 callAction 方法中而不是在控制器的构造函数中初始化变量有什么意义?
use Illuminate\Routing\Controller;
class ControllerA extends Controller
{
protected $data = [];
public function callAction($method, $parameters)
{
$this->data['title'] = 'Some database query';
}
public function index(Request $request)
{
return view('index', $this->data);
}
}
【问题讨论】:
标签: php laravel laravel-routing laravel-controller