Commit e8f31bbf authored by Nicolas Widart's avatar Nicolas Widart

Adding a weight sorting option for the sidebar items

parent 2bba2a1a
<?php namespace Modules\Core\Composers;
class SidebarViewComposer
{
public function compose($view)
{
$view->items->sort(function($item1, $item2) {
if (is_object($item1)) {
if ($item1->first()['weight'] > $item2['weight']) {
return 1;
}
if ($item1->first()['weight'] < $item2['weight']) {
return -1;
}
return 0;
}
if (is_object($item2)) {
if ($item1['weight'] > $item2->first()['weight']) {
return 1;
}
if ($item1['weight'] < $item2->first()['weight']) {
return -1;
}
return 0;
}
if ($item1['weight'] > $item2['weight']) {
return 1;
}
if ($item1['weight'] < $item2['weight']) {
return -1;
}
return 0;
});
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment