Ejemplo n.º 1
0
 public function run()
 {
     // Category Seeds
     Example::truncate();
     $i = 0;
     foreach (explode(' ', "This plugin is just a proof of concept. Have fun!") as $label) {
         Example::create(['position' => $i, 'label' => $label, 'active' => 1]);
         $i++;
     }
     foreach (explode(' ', "---------- These rows are disabled!") as $label) {
         Example::create(['label' => $label, 'active' => 0]);
     }
 }
Ejemplo n.º 2
0
 public function index_onUpdatePosition()
 {
     $moved = [];
     $position = 0;
     if (($reorderIds = post('checked')) && is_array($reorderIds) && count($reorderIds)) {
         foreach ($reorderIds as $id) {
             if (in_array($id, $moved) || !($record = Example::find($id))) {
                 continue;
             }
             $record->position = $position;
             $record->save();
             $moved[] = $id;
             $position++;
         }
         Flash::success('Successfully re-ordered records.');
     }
     return $this->listRefresh();
 }