Create Model Sequences With the Eloquent Sequencer Package

Create Model Sequences With the Eloquent Sequencer Package

Eloquent Sequencer is a package by Gustavo R. Gentil for automatically sequencing your models when adding new records. This package makes it trivial to rearrange things like todos, cards, or lists of models.

Here’s an example from the readme demonstrating a task list that has many Task models:

use Gurgentil\LaravelEloquentSequencer\Traits\Sequenceable;
use Illuminate\Database\Eloquent\Model;

class Task extends Model
    use Sequenceable;

    protected static $fillable = [

    protected static $sequenceableKeys = [

    public function taskList()
        return $this->belongsTo(TaskList::class);

Let’s say that you have a drag and drop interface for reordering tasks. You could call the following methods, and this package will automatically rearrange the sequence of tasks:

// Other items in the sequence will be rearranged
$task->update(['position' => 4]);

// Remaining tasks will be rearranged after removing a task

Finally, you’d use the following method to get the sequenced list of tasks:

$tasks = Task::sequenced()->get();

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub at gurgentil/laravel-eloquent-sequencer.

Filed in: News
Laravel News Partners

Laravel Jobs

Backend Software Engineer (PHP Developer)
Austin TX, Bonita Springs FL
Certified eSupport Corp
Backend PHP Developer
Hamburg, Germany
Full-Stack Engineer (Mid to Senior)
Remote (EST, CST)
Senior Laravel Developer (AI Applications)
Remote from anywhere in the UK or from our London office
GreenShoot Labs
Full Stack Engineer


Join 31,000+ others and never miss out on new tips, tutorials, and more.