public function getIndex() { $slides = Slide::all(); foreach ($slides as $slide) { $slide->flame = Flame::findOrFail($slide->flame_id); } return Response::json($slides); }
public function postEdit(Request $request) { if ($request->input('flame_id')) { $flame = Flame::findOrFail($request->input('flame_id')); } else { $flame = new Flame(); } $flame->title = $request->input('title'); $flame->champion_ids = $request->input('champion_ids'); $flame->type_ids = $request->input('flame_types'); $flame->user_id = Auth::user()->id; $flame->updated_at = time(); if ($request->hasFile('file') && $request->file('file')->isValid()) { $filename = time() . '.' . $request->file('file')->getClientOriginalExtension(); $request->file('file')->move('assets/sfx', $filename); $flame->filepath = $filename; } $flame->save(); return redirect()->action('HomeController@getIndex'); }