1use Illuminate\Support\Facades\Validator;
2
3# most likely you will need these 2 too
4use Illuminate\Support\Facades\Hash;
5use App\User;
1use Response;
2Or use full namespace:
3
4return \Response::json(...);
5Or just use helper:
6
7return response()->json(...);
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