php - Laravel 4: Updating table Joins with form model binding -
i once did eager loading query , worked. using model binding i'm trying update 2 tables @ once no lucky. no error thrown, validations fine , when tried var_dump see values after validation , there. can't way update 2 tables in database using eloquent @ time. please help.
here did 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, can not update profile. try again!'); } return redirect::route('profile.edit', $user->username)->with('form-success', 'profile has been updated!'); } public function getuserbyusername($username) { return user::with('profile')->whereusername($username)->firstorfail(); }
other files can found here: http://laravel.io/bin/8ejk5
Comments
Post a Comment