GrafiteInc / CMS

Decoupled CMS for any Laravel app, gain control of: pages, blogs, galleries, events, images, custom modules and more.
https://cms.grafite.ca
MIT License
495 stars 104 forks source link

Deleting menu link does not remove it's id from menus.order column #176

Closed jpranskaitis closed 5 years ago

jpranskaitis commented 5 years ago

To repeat this issue just create 'main' menu add two links to it, change the sorting of them, delete one link and open a page that shows 'main' menu.

[2018-09-19 13:53:20] local.ERROR: Undefined offset: 4 (View: /public_html/resources/themes/front/partials/navigation.blade.php)

mlantz commented 5 years ago

Will issue a fix as soon as possible

jpranskaitis commented 5 years ago

Thanks.

Also great idea would be to use protected $casts for json operations.

Like:

class Menu extends CmsModel { //... protected $casts = [ 'order' => 'array' ] //... }

Laravel would parse the field for you and you will not need to encode/decode it anywhere. One drawback is that you will not be able to do ->update(['order' => $order_array) directly, but

$menu->order = $order_array; $menu->save();

would work like a charm.

mlantz commented 5 years ago

Will look at making those adjustments, thanks