gpt4 book ai didi

php - BadMethodCallException 方法 orderBy 不存在

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:59 25 4
gpt4 key购买 nike

型号

<?php

class CommentComentario extends Illuminate\Database\Eloquent\Model {

protected $table = 'comment_comentario';

public function comercio() {
return $this->belongsTo('CommentComercio', 'comercio_id', 'id');
}
}

请求

$comercios = CommentComercio::all()->orderBy('created_at');

Error is produced in illuminate\support\Traits\Macroable.php line 81

安装 Composer

{
"require": {
"slim/slim": "2.*",
"slim/extras": "*",
"illuminate/console": "*",
"illuminate/database": "*",
"illuminate/events": "*",
"illuminate/filesystem": "*",
"facebook/php-sdk-v4": "*",
"monolog/monolog": "1.*",
"twig/twig": "*",
"phpmailer/phpmailer": "~5.2"
},
"autoload": {
"classmap": [ "models" ]
}
}

最佳答案

改变这一行:

$comercios = CommentComercio::all()->orderBy('created_at');

对此:

$comercios = CommentComercio::orderBy('created_at')->get();

这将得到“所有”你的元素,但订单已应用到它。

关于php - BadMethodCallException 方法 orderBy 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34318782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com