1Resource Controller:This controller will create all CRUD methods
2php artisan make:controller nameOfController --resource
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...