本文整理汇总了PHP中app\models\Profile::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::fill方法的具体用法?PHP Profile::fill怎么用?PHP Profile::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Profile
的用法示例。
在下文中一共展示了Profile::fill方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCreate
public function postCreate()
{
$postValue = $this->getProfileInput();
$profile = new Profile();
if ($profile->validate($postValue)) {
$profile->fill($postValue);
$profile->save();
return redirect(route('home'));
} else {
return view('profile.create', compact('profile'));
}
}
示例2: createOrUpdateProfile
public function createOrUpdateProfile($user, $data)
{
$profile = $user->profile;
if (!$profile) {
$profile = new Profile();
}
DB::beginTransaction();
try {
$profile->fill($data);
if ($user->profile()->save($profile)) {
DB::commit();
return $user;
} else {
DB::rollback();
return false;
}
} catch (Exception $ex) {
DB::rollback();
return false;
}
}
示例3: update
/**
* Update a user's profile
*
* @param $username
* @return mixed
* @throws Laracasts\Validation\FormValidationException
*/
public function update($username, Request $request)
{
$user = $this->getUserByUsername($username);
$input = Input::only('location', 'bio', 'twitter_username', 'github_username', 'career_title', 'education');
$profile_validator = $this->profile_validator($request->all());
if ($profile_validator->fails()) {
$this->throwValidationException($request, $profile_validator);
return redirect('profile/' . $user->name . '/edit')->withErrors($validator)->withInput();
}
if ($user->profile == null) {
$profile = new Profile();
$profile->fill($input);
$user->profile()->save($profile);
} else {
$user->profile->fill($input)->save();
}
return redirect('profile/' . $user->name . '/edit')->with('status', 'Profile updated!');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$create_new_validator = $this->create_new_validator($request->all());
if ($create_new_validator->fails()) {
$this->throwValidationException($request, $create_new_validator);
} else {
$activation_code = str_random(60) . $request->input('email');
$user = new User();
$user->email = $request->input('email');
$user->name = $request->input('name');
$user->first_name = $request->input('first_name');
$user->last_name = $request->input('last_name');
$userAccessLevel = $request->input('user_level');
$user->password = bcrypt($request->input('password'));
// GET ACTIVATION CODE
$user->activation_code = $activation_code;
$user->active = '1';
// GET IP ADDRESS
$userIpAddress = new CaptureIp();
$user->admin_ip_address = $userIpAddress->getClientIp();
// SAVE THE USER
$user->save();
// ADD ROLE
$user->assignRole($userAccessLevel);
// CREATE PROFILE LINK TO TABLE
$profile = new Profile();
$profileInputs = Input::only('location', 'bio', 'twitter_username', 'github_username');
$profile->fill($profileInputs);
$user->profile()->save($profile);
// THE SUCCESSFUL RETURN
return redirect('edit-users')->with('status', 'Successfully created user!');
}
}