[Custom Module] Sortable entries after first migration and selecting in order
damian_nz - 10 months ago
Hi 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?
ryanthompson - 10 months ago
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.