public function updateOrder(Request $request) { $timeline = new Timeline(); $results = $timeline->updateOrder($request); if (!$results) { return redirect()->route('cpanel.timeline.index')->with('status', 'fail')->with('msg', 'Can not update order.'); } else { return redirect()->route('cpanel.timeline.index')->with('status', 'success')->with('msg', 'Successfully !'); } }
public function updateOrder($request) { $order = $request->input('order'); if ($order) { foreach ($order as $key => $value) { $time_line = Timeline::find($key); $time_line->order = $value; $time_line->update(); } } return ""; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // Get history $list_histories = Timeline::with(['timelineDetails' => function ($query) { $query->where('language_code', '=', App::getLocale()); }])->orderBy('order', 'asc')->get(); $about_service = StaticPage::with(['pageDetails' => function ($query) { $query->where('language_code', '=', App::getLocale()); }])->where('properties', '=', 7)->firstOrFail(); $why_vietnam = StaticPage::with(['pageDetails' => function ($query) { $query->where('language_code', '=', App::getLocale()); }])->where('properties', '=', 8)->firstOrFail(); $message_ceo = StaticPage::with(['pageDetails' => function ($query) { $query->where('language_code', '=', App::getLocale()); }])->where('properties', '=', 9)->firstOrFail(); return view('about', compact('list_histories', 'about_service', 'why_vietnam', 'message_ceo')); }