{"repo":"boxfrommars/rutorika-sortable","free":true,"listed":false,"github":"https://github.com/boxfrommars/rutorika-sortable","clone":"git clone https://github.com/boxfrommars/rutorika-sortable.git","description":"Adds sortable behavior to Laravel Eloquent models","language":"PHP","stars":289,"topics":["php","laravel","sortable","ordering","sorting"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Laravel 5 - Demo https://github.com/boxfrommars/rutorika-sortable-demo5 Install Install package through Composer Version Compatibility Laravel Rutorika Sortable :-------------------------- :---------------------- 4 1.2.x (branch laravel4) Note : Resorting does not take place after a record is deleted. Gaps in positional values do not affect the ordering of your lists. However, if you prefer to prevent gaps you can reposition your models using the deleting event. Something like: You need rutorika-sortable =2.3 to use - next() Sortable groups if you want group entity ordering by field, add to your model now moving and ordering will be encapsulated by this field. If you want group entity ordering by many fields, use as an array: Sortable many to many Let's assume your database structure is and you want to order tags for each post Add position column to the pivot table (you can use any name you want, but position is used by default) Add \\Rutorika\\Sortable\\BelongsToSortedManyTrait to your Post model and define belongsToSortedMany relation provided by this trait: Note: $this- belongsToSortedMany has different signature then $this- belongsToMany -- the second argument for this method is $orderColumn ( 'position' by default), next arguments are the same Attaching tags to post with save / sync / attach methods will set proper position Getting related model is sorted by position You can reorder tags for given post Many to many demo: http://sortable5.boxfrommars.ru/posts (code) You can ","default_branch":null,"files":null,"tree":[],"storefront":"/r/boxfrommars","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/boxfrommars/rutorika-sortable/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}