public function store(Request $request) { $validation = Validator::make($request->all(), ['dvd' => 'required', 'genre' => 'required', 'rating' => 'required', 'label' => 'required', 'sound' => 'required', 'format' => 'required']); if ($validation->fails()) { return redirect('dvds/create')->withInput()->withErrors($validation); } $dvd = new Dvd(['title' => $request->input('dvd'), 'genre_id' => $request->input('genre'), 'rating_id' => $request->input('rating'), 'label_id' => $request->input('label'), 'sound_id' => $request->input('sound'), 'format_id' => $request->input('format')]); $dvd->save(); return redirect('dvds/create')->with('success', true); }
public function store(Request $request) { $validation = Validator::make($request->all(), ['title' => 'required|unique:dvds,title']); if ($validation->passes()) { $dvd = new Dvd(); $dvd->title = $request->input('title'); $dvd->save(); return ['dvd' => $dvd]; } return Response::json(['errors' => ['title' => $validation->errors()->get('title')]], 422); }
public function store(Request $request) { $dvd = new Dvd(); $dvd->title = $request->title; $dvd->genre_id = $request->genre; $dvd->rating_id = $request->rating; $dvd->label_id = $request->label; $dvd->sound_id = $request->sound; $dvd->format_id = $request->formatId; $dvd->save(); return redirect("create")->with('success', true); }
public function store(Request $request) { $validation = Validator::make($request->all(), ['title' => 'required|unique:dvds', 'award' => 'required', 'genre_id' => 'required|integer|exists:genres,id', 'rating_id' => 'required|integer|exists:ratings,id']); if ($validation->passes()) { $dvd = new Dvd(); $dvd->title = $request->input('title'); $dvd->award = $request->input('award'); $dvd->genre_id = $request->input('genre_id'); $dvd->rating_id = $request->input('rating_id'); $dvd->save(); return ['dvd' => $dvd]; } return Response::json(['errors' => ['title' => $validation->errors()->get('title'), 'award' => $validation->errors()->get('award'), 'genre_id' => $validation->errors()->get('genre_id'), 'rating_id' => $validation->errors()->get('rating_id')]], 422); }
public function store(Request $request) { $validation = Validator::make($request->all(), ['title' => 'required']); if ($validation->fails()) { return redirect('dvds/create')->withInput()->withErrors($validation); } $dvd = new Dvd(); $dvd->title = $request->input('title'); $dvd->format_id = $request->input('format'); $dvd->label_id = $request->input('label'); $dvd->sound_id = $request->input('sound'); $dvd->genre_id = $request->input('genre'); $dvd->rating_id = $request->input('rating'); $dvd->save(); return redirect('dvds/create')->withFlashMessage('DVD Was Added Successfully.'); }
public function addDvd(Request $request) { $title = $request->input('title'); $genre_id = $request->input('genre_id'); $rating_id = $request->input('rating_id'); $format_id = $request->input('format_id'); $label_id = $request->input('label_id'); $sound_id = $request->input('sound_id'); $dvd = new Dvd(); $dvd->title = $title; $dvd->genre_id = $genre_id; $dvd->rating_id = $rating_id; $dvd->format_id = $format_id; $dvd->label_id = $label_id; $dvd->sound_id = $sound_id; $validation = Validator::make($request->all(), ['title' => 'Required']); if ($validation->fails()) { return redirect("/dvds/create")->withInput()->withErrors($validation); } else { $dvd->save(); return redirect("dvds/create")->with('success', true); } }