laravel resource controller create example

Solutions on MaxInterview for laravel resource controller create example by the best coders in the world

showing results for - "laravel resource controller create example"
Silvana
10 Jan 2021
1Route::resource('photos', PhotoController::class)->only([
2    'index', 'show'
3]);
4
5Route::resource('photos', PhotoController::class)->except([
6    'create', 'store', 'update', 'destroy'
7]);
Cordelia
08 Jun 2016
1Route::resource('photos', PhotoController::class);
Philomena
15 Jan 2016
1<?php
2...
3    /**
4        * Store a newly created resource in storage.
5        *
6        * @return Response
7        */
8    public function store()
9    {
10        // validate
11        // read more on validation at http://laravel.com/docs/validation
12        $rules = array(
13            'name'       => 'required',
14            'email'      => 'required|email',
15            'shark_level' => 'required|numeric'
16        );
17        $validator = Validator::make(Input::all(), $rules);
18
19        // process the login
20        if ($validator->fails()) {
21            return Redirect::to('sharks/create')
22                ->withErrors($validator)
23                ->withInput(Input::except('password'));
24        } else {
25            // store
26            $shark = new shark;
27            $shark->name       = Input::get('name');
28            $shark->email      = Input::get('email');
29            $shark->shark_level = Input::get('shark_level');
30            $shark->save();
31
32            // redirect
33            Session::flash('message', 'Successfully created shark!');
34            return Redirect::to('sharks');
35        }
36    }
37...
similar questions
queries leading to this page
laravel resource controller create example