in the store function in my controller I have:
public function store()
{
$validator = Validator::make($data = Input::all(), Item::$rules);
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
Item::create($data);
return Redirect::route('spesas.index');
}
What is missing is the user_id field.
I tought since the inserting user is the auth one, to not pass the id via POST, but retrieve it with Auth::user() in the controller (It seemed more secure).
Now I have the problem to insert the Auth::user() id in the input fields before Item::create($data);
Am I doing the Right Thing? Any suggestions?
Thanks,
$data['user_id'] = Auth::id();before creating the item?