/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($id) { $tour = Tour::findOrFail($id); $input = Request::all(); $data = Tour::whereRaw('alias = ? AND id != ?', [$input['alias'], $id])->first(); if (!empty($data)) { $input['alias'] = create_permalink($input['alias']); } $photos = []; if (!empty($input['photo'])) { $temp = count($input['photo']); for ($i = 0; $i < $temp; $i++) { $photos[] = ['src' => $input['photo'][$i], 'title' => $input['title_img'][$i], 'desc' => $input['desc_img'][$i]]; } $input['photos'] = json_encode($photos); } $input['destinations'] = destination_encode($input['destinations']); $tour->fill($input)->save(); Session::flash('flash_message', 'Task successfully added!'); return redirect()->back(); }