[Custom Module] Sortable entries after first migration and selecting in order
Created 6 years ago by damian_nzHi there, I have a stream in a custom module that has been in production for about a year. A new requirement has come up and I want to be able to sort them as you can with pages by dragging.
I have made a new migration and tried simply doing
protected $stream = [
'slug' => 'filters',
'sortable' => true
];
Unfortunately this didn't work.
Is it possible to make a stream sortable after the initial migration?
Then when it is working, how do I query to get it in the sorted order? Or will that happen automatically?
Thank you
If you are trying to simply make them sortable in a table - this is all you need. But you mention pages which are nested. So you would need to use the tree builder instead of the table builder in your controllers.
Again it'll sort by sort order by default assuming the migration was accurate but nested will require parent
field to work properly in the tree builder.
Ya what’s your streams_streams table look like for the stream in question? Should have it’s aortable column true. Any options on your table builder that would be forcing any certain order otherwise?
I don't think that method of migration allows for updating it only defines the stream to use for subsequent assignments in the shorthand method. My suggestion when modifying fields / assignments / streams after they're created would be to use the normal up/down methods and the included repositories:
$stream = $this->streams()->findBySlugAndNamespace('foo', 'bar');
$stream->sortable = true;
$stream->save();
That will update the DB, update the models, etc.
I don't think that method of migration allows for updating it only defines the stream to use for subsequent assignments in the shorthand method. My suggestion when modifying fields / assignments / streams after they're created would be to use the normal up/down methods and the included repositories:
That will update the DB, update the models, etc.