首页 > 解决方案 > Laravel刀片文件无法查看

问题描述

我在 Http 中创建了 CustomerController,后来,我固定路由获取客户,但在单个操作控制器中出现错误。

我试图炫耀 CustomerController 视图以显示客户登录页面

编码错误图像

这是我的错误信息:

使用未定义的常量视图 - 假定为“视图”(这将在 PHP 的未来版本中引发错误)

标签: laravel-5.8

解决方案


看起来您正在尝试访问渲染刀片文件的旧方法,请看:-

 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


推荐阅读