public function getTerraceLiving() { $terraces = TerraceLivingPage::orderBy('order_id')->get(); return View::make('site.terrace-living', array('terraces' => $terraces)); }
public function updateSortableElements($type) { $ids = Input::get('item'); if ($type == 'amenities') { for ($i = 0; $i < count($ids); $i++) { $amenitie = Amenitie::where('id', '=', $ids[$i])->first(); var_dump($amenitie->toJson()); $amenitie->update(array('order_id' => $i + 1)); } } else { if ($type == 'residences') { for ($i = 0; $i < count($ids); $i++) { $residence = Residence::where('id', '=', $ids[$i])->first(); $residence->update(array('order_id' => $i + 1)); } } else { if ($type == 'home') { for ($i = 0; $i < count($ids); $i++) { $residence = HomePage::where('id', '=', $ids[$i])->first(); $residence->update(array('order_id' => $i + 1)); } } else { if ($type == 'terrace') { for ($i = 0; $i < count($ids); $i++) { $residence = TerraceLivingPage::where('id', '=', $ids[$i])->first(); $residence->update(array('order_id' => $i + 1)); } } else { echo 'Non sortable type'; } } } } }