I am using Laravel 5.2 ..
There is a user and a profile table,it is a one-to-one relationship between them,
in ProfileController,
after user login,
when access create function,
if user's profile has not been created,return create page,
else,
redirect to edit function.
Question:
How to write the create function and edit function?
I writed a part of them.
1、how to write the parameter id in create function?
2、how to find the profile of the login user in edit function?
ProfileController:
public function create()
{
$user = \Auth::user();
if (!$user->profile) {
return view('profile.create');
}else{
//how to write 'id'
return redirect()->action('ProfileController@edit', ['id' => .......]);
}
}
public function edit()
{
//how to find the profile of the login user?
return view('profile.edit', compact('profile'));
}
User::create(): laravel.com/docs/master/eloquent#events