laravel-5.8 - Laravel刀片文件无法查看
问题描述
我在 Http 中创建了 CustomerController,后来,我固定路由获取客户,但在单个操作控制器中出现错误。
我试图炫耀 CustomerController 视图以显示客户登录页面
这是我的错误信息:
使用未定义的常量视图 - 假定为“视图”(这将在 PHP 的未来版本中引发错误)
解决方案
看起来您正在尝试访问渲染刀片文件的旧方法,请看:-
return View::make('customers.index', $customersList);
使用view()方法
return view('admin.pages.customers.index',compact('someVaiable'));
OR
// You can define constant for your controller get methods
private $layout;
public function __construct()
{
$this->layout = 'admin.pages.customers.';
}
public function index(){
return view($this->layout.'index');
}
看看这个单动作控制器的例子
https://laravel.com/docs/5.8/controllers#single-action-controllers
推荐阅读
- linq - 我想执行字符串格式的 linq 查询。有没有办法将字符串作为 linq to sql 执行
- windows - 如何为 Windows 和 Mac 编写一个设置环境变量的 Makefile?
- c++ - 为什么 CMake 无法找出 Eigen3 的正确版本?
- python - 如何解决 Gdk-CRITICAL **:17:13:03.280:gdk_cursor_new_for_display:断言“GDK_IS_DISPLAY(显示)”失败
- rsyslog - 从 Zscaler 接收日志时,文件名 Ubuntu rsyslog 中的特殊字符是什么?
- javascript - 如何从父 div 获取特定子元素的内部元素 - selenium javascript
- c++ - 带花括号的引用类型变量上的 decltype
- python - 在 sympy 中解决的性能问题
- command-line-interface - 如何使用 Azure DevOps cli 检索工作项的 Azure DevOps 版本
- r - 复制的 ggplot-object 与原始对象部分链接