本文整理汇总了PHP中app\models\User::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP User::fill方法的具体用法?PHP User::fill怎么用?PHP User::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
$user = new User();
$user->fill(['name' => 'Erick Mo', 'email' => 'mo@thunderlab.id', 'password' => '123123123']);
$user->save();
}
示例2: createUser
private static function createUser(Hybrid_User_Profile $profile)
{
$user = new User();
$data = ['email' => $profile->email ? $profile->email : null, 'name' => $profile->displayName, 'avatar' => $profile->photoURL, 'country' => $profile->country, 'gender' => $profile->gender, 'region' => $profile->region, 'phone' => $profile->phone, 'city' => $profile->city, 'address' => $profile->address, 'birthday' => $profile->birthYear . '-' . $profile->birthMonth . '-' . $profile->birthDay, 'language' => $profile->language];
$user->fill($data);
$user->token = md5(sha1(\Config::get('app.key') . microtime() . rand()));
$user->save();
return $user;
}
示例3: register
public function register($data)
{
$roleUser = Role::getRoleByName('user');
$user = new User();
$user->fill($data);
$user->setAttribute('status', true);
$user->setAttribute('role_id', $roleUser->id);
return $user->save();
}
示例4: store
/**
*
*/
public function store(CreateUserRequest $request)
{
$user = new User();
$user->fill($request->all());
$user->company_id = Auth::user()->company_id;
$user->password = bcrypt($request->input('password'));
$user->save();
Flash::success(trans('users/general.status.created'));
return redirect('/users');
}
示例5: store
public function store(array $input)
{
$user = new User();
$user->fill($input);
$user = $this->setPassword($user, $input);
$user->save();
$this->linkToRole($user, $input);
$this->linkToFaculty($user, $input);
return $user;
}
示例6: doAdd
public function doAdd(Request $request)
{
$user_form = $request->get('user');
$user = new User();
$user->fill($user_form);
$user->password = Hash::make($user_form['password']);
$user->faculty_id = $user_form["faculty_id"];
$user->save();
$user->roles()->sync($user_form["role_ids"]);
return redirect('/backend/user');
}
示例7: store
public function store(Request $request)
{
$user = new User();
$user->fill($request->all());
$user->password = Hash::make($request->get('password'));
if ($request->get('name') == "" || $request->get('email') == "" || $request->get('password') == "") {
$request->session()->flash('error', 'Something was left blank');
return redirect('/register');
} else {
Auth::login($user);
return redirect('/#/editUser/' . $user->id);
}
}
示例8: register
public function register(Request $request)
{
$fields = array('email', 'password');
foreach ($fields as $field) {
if (!$request->input($field)) {
return response()->json(array('error' => 'Missing field: ' . $field), 400);
}
}
if (User::where('email', '=', $request->input('email'))->first()) {
return response()->json(array('error' => 'An account already exists with this email address.'), 400);
}
$user = new User();
$user->fill($request->all());
$user->password = User::hashedPassword($request->input('password'));
$user->save();
return $this->login($request);
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$user = new User();
$user->fill($request->all());
$user->status_level = 0;
$user->password = \Hash::make($request->password);
$user->save();
$scores = new Score();
$scores->user_id = $user->id;
$scores->value = 0;
$scores->save();
\Mail::send('emails.new_user', ['user' => $user], function ($message) use($user) {
$message->to("airtonmfilho@hotmail.com", $user->name)->subject(trans('emails.new_user_title'));
});
\Auth::attempt(array('email' => $request->email, 'password' => $request->password));
return redirect()->intended('/profile');
}
示例10: store
/**
* Store user
*
* @param array $data
* @throws NotFoundException, ValidationException
* @return \App\Models\UserModel
*/
public function store($data)
{
if (!array_get($data, 'password')) {
unset($data['password']);
}
try {
if (array_get($data, 'id')) {
$user = UserModel::findOrFail((int) array_get($data, 'id'));
// if this user's email is the same as what the data, then it's ok; otherwise, it has to be unique
if (array_get($data, 'email') && $user->email == array_get($data, 'email')) {
$user->removeRule('email');
}
$user->fill($data);
} else {
$user = new UserModel();
$user->fill($data);
}
} catch (Exception $e) {
throw new NotFoundException(trans('app.notFound'));
}
if (!array_get($data, 'password')) {
$user->removeRule('password');
}
if (!$user->validate()) {
throw new ValidationException(trans('app.correctErrors'), $user->errors()->toArray());
}
if (array_get($data, 'password')) {
$user->password = bcrypt($data['password']);
}
unset($user->password_confirmation);
try {
$user->save();
} catch (Exception $e) {
throw $e;
}
return $user;
}
示例11: loginFacebookUser
/**
* This method save or log in a user when is using FacebookAccount
* @param $request
* @return \Symfony\Component\HttpFoundation\Response
*/
private function loginFacebookUser($request)
{
//load the facebook SDK object
$fb = new Facebook(['app_id' => env('FB_API_ID'), 'app_secret' => env('FB_API_SECRET'), 'default_graph_version' => 'v2.2']);
//set the token that whe receive from the request APP
$fb->setDefaultAccessToken($request->input('token'));
//Get the graph query
try {
$response = $fb->get('/me?fields=id,name,email');
$fbUser = $response->getGraphUser();
} catch (FacebookResponseException $e) {
return response()->json($e->getMessage(), 401);
} catch (FacebookSDKException $e) {
return response()->json($e->getMessage(), 400);
}
//instantiate the new user
$user = new User();
//find by facebook_id and get the mongodb collection for users
$users = $user->getCollection();
$result = $users->findOne(['facebook_id' => $fbUser['id']]);
if ($result) {
var_dump('log in process by idfb');
die;
}
//find by email
$result = $users->findOne(['email' => $fbUser['email']]);
if ($result) {
var_dump('log in process by email');
die;
}
//if not found then fill data and save account
$user->fill($request);
if (!$user->save()) {
return response()->json('Error, the user was not created', 400);
}
return response()->json('success', 200);
}
示例12: postUserUnban
public function postUserUnban(User $user)
{
$user->fill(['banned' => false])->save();
flash()->success(trans('messages.admin.unbanned_user', ['name' => $user->name]));
return redirect()->back();
}
示例13: update
/**
* Update user
*
* @param User $user
* @param array $data
*/
public static function update(User $user, $data = array())
{
$user->fill($data);
$user->update();
}
示例14: update
public function update(User $user, Request $request)
{
$user->fill($request->input())->save();
return redirect()->route('users.index');
}
示例15: store
/**
* store a resource
* @param Request $this->request http request
* @param mixed $id id of the resource for updating
* @return jsend jsend with newly stored source
*/
function store($id = null)
{
////////////////
// Load Data //
////////////////
if ($id) {
$data = Model::find($id);
if (!$data) {
return app()->abort(404);
}
} else {
$data = new Model();
}
///////////////////////////////////
// Assign posted data to Data //
///////////////////////////////////
$data->fill($this->request->input());
///////////////////////
// EMBED IMAGES //
///////////////////////
foreach ($this->request->input('images') as $x) {
$images[] = new Image($x);
}
if (!$data->syncImages($images)) {
return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
}
///////////////////////
// EMBED AUTH //
///////////////////////
foreach ($this->request->input('auths') as $x) {
$auths[] = new Auth($x);
}
if (!$data->syncAuths($auths)) {
return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
}
///////////////////////
// EMBED ACCOUNT //
///////////////////////
foreach ($this->request->input('account_connects') as $x) {
$accounts[] = new AccountConnect($x);
}
if (!$data->syncAccountConnects($accounts)) {
return response()->json(JSend::fail($data->getErrors())->asArray())->setCallback($this->request->input('callback'));
}
///////////
// Store //
///////////
if ($data->save()) {
/////////////////////
// Return Response //
/////////////////////
return response()->json(JSend::success(['data' => $data->toArray()])->asArray());
} else {
return response()->json(JSend::fail($data->getErrors())->asArray());
}
}