santino
4 months ago

spatie / eloquent-sortable - Please help to integrate spatie code... HELP

Posted 4 months ago by santino

Hi community, please I want to implement sspatie ssortable pack but am tuck with this instruction

Usage

To add sortable behaviour to your model you must:

Implement the Spatie\EloquentSortable\Sortable interface. Use the trait Spatie\EloquentSortable\SortableTrait. Optionally specify which column will be used as the order column. The default is order_column. Example


Example
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;



class MyModel extends Eloquent implements Sortable
{

    use SortableTrait;

    public $sortable = [
        'order_column_name' => 'order_column',
        'sort_when_creating' => true,
    ];
    
    ...
}

can you help?

https://github.com/spatie/eloquent-sortable

thanks

MY MODEL =

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Section extends Model
{

	public function course()
	{
		return $this->belongsTo( 'App\Course');
	}

	public function lessons()
	{
		return $this->hasMany( 'App\Lesson');
	}



}

Please sign in or create an account to participate in this conversation.