BadMethodCallException方法orderBy不存在


BadMethodCallException Method orderBy does not exist

型号

<?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');

错误出现在illumination''support''Traits''MMacroable.php第81行中

图片编辑器

{
    "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();

这将仍然获得"所有"您的物品,但已应用订单。