Can't model orderBy sort_order

Hello,

I’m trying to:

$ledTickers = LedTickerModel::sortBy('sort_order', 'ASC')->get();

in a component.

It throws following error:

Call to undefined method Maki3000\LedTicker\Models\LedTicker::sortBy()

Here’s my model:

<?php namespace Maki3000\LedTicker\Models;

use Model;

/**
 * Model
 */
class LedTicker extends Model
{
    use \October\Rain\Database\Traits\Validation;
    use \October\Rain\Database\Traits\Sortable;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'maki3000_ledticker_ledticker';

    /**
     * @var array Validation rules
     */
    public $rules = [
    ];
}

Here’s part of my migration:

<?php namespace Maki3000\LedTicker\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

class BuilderTableCreateMaki3000LedtickerLedticker extends Migration
{
    public function up()
    {
        Schema::create('maki3000_ledticker_ledticker', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->string('name');
            $table->string('slug');
            ...
            $table->integer('sort_order')->unsigned()->default(0);
            $table->timestamp('created_at')->nullable();
            $table->timestamp('updated_at')->nullable();
        });
    }

    public function down()
    {
        Schema::dropIfExists('maki3000_ledticker_ledticker');
    }
}

Strange thing is that I’m doing exactly the same on another component and there it works…

I think it should be orderBy

OMG! Thanks! I almost thought, that it would be something that silly of me :man_facepalming:

1 Like