'Why im still getting this error on laravel web, it says about non-statically method.'



这是错误

不能静态调用非静态方法App\Models\ISModel::DisplayAllUserList((

这是我在控制器中的代码

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesDB;
use AppModelsISModel;
class ISController extends Controller
{
public function display_all_user_list(){

echo $result = ISModel::DisplayAllUserList();
}
}

请回答我的问题,谢谢!

欢迎使用Laravel,雄辩的模型不像构造函数那样工作——你不能只在Model实例上调用一个方法,你必须准确地定义你想要的东西,所以既然你想返回所有模型,你就这样做

ISModel::all()->DisplayAllUserList();

我仍然认为这可能会导致问题,因为您正在向集合调用一个方法,但您返回了所有像这样的ISModel。

相关内容

最新更新