1public function store()
2 {
3 $rules = array(
4 'name' => 'required',
5 );
6
7 $validator = Validator::make(Input::all(), $rules);
8
9 // if the validator fails, redirect back to the form
10 if ($validator->fails()) {
11 return Redirect::back()
12 ->withErrors($validator) // send back all errors to the login form
13 ->withInput();
14
15 $input = input::all();
16
17 } else {
18
19 $company = New Company();
20 $company->name = Input::get('name');
21 $company->user_id = Input::get('user_id');
22 $company->country_id = Input::get('country_id');
23 $company->description = Input::get('description');
24
25 $company->save();
26
27 return Redirect::to('/backend')->withInput()->with('success', Company added.');
28
29 }
30 }
31