I once did an eager loading query and it worked. Then using model binding i'm trying to update my two tables at once with no lucky. No error thrown, all validations are fine and when i tried to var_dump to see the values after validation , they are all there. I just can't get a way to update two tables in database using eloquent at a time. Please help.
Here is what i did so far:
ProfilesController.php
public function update($username)
{
$user = $this->getUserByUsername($username);
$input = Input::all();
try {
$this->profileForm->validate($input);
// dd($input);
$user->profile->update($input);
} catch (FormValidationException $e) {
return Redirect::back()->withInput()->withErrors($e->getErrors())->with('form_error', 'Sorry, we can not update your profile. Try again!');
}
return Redirect::route('profile.edit', $user->username)->with('form-success', 'Profile has been successfully updated!');
}
public function getUserByUsername($username)
{
return User::with('profile')->whereUsername($username)->firstOrFail();
}
Other files can be found here: http://laravel.io/bin/8eJK5