【发布时间】:2019-01-28 23:42:41
【问题描述】:
如何传递一个可以被 Laravel 中的 view() 方法解析的变量?
public function index($department_id) {
$employees=Employee::all();
$department=Department::find($department_id);
return view('departments.$department->department_code.index')->with('department',$department)->with('employees', $employees);
}
这个想法是每个部门都有一个与部门模型中的部门代码同名的部门文件夹。我希望能够接收 department_id,检索正确的部门,然后返回包含部门所有属性的适当视图。
当我尝试这样做时,我收到此错误InvalidArgumentException
View [departments.$department->department_code.index] not found.。
【问题讨论】: