当前位置: 首页>>代码示例>>PHP>>正文


PHP User::toArray方法代码示例

本文整理汇总了PHP中app\models\User::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP User::toArray方法的具体用法?PHP User::toArray怎么用?PHP User::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::toArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Execute the job.
  *
  * @param JWT $jwt
  * @param Carbon $carbon
  * @return String
  */
 public function handle(JWT $jwt, Carbon $carbon)
 {
     $timestamp = $carbon->now()->timestamp;
     $data = collect($this->user->toArray())->only('id')->merge(compact('timestamp'));
     $token = $jwt->encode($data, env('APP_KEY'));
     /**
      * Save token on the user model
      */
     if ($this->saveToken) {
         $this->user->setAttribute('api_token', $token);
         $this->user->save();
     }
     return $token;
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:21,代码来源:GenerateTokenJob.php

示例2: sendResetPasswordInfo

 public function sendResetPasswordInfo(User $user, PasswordResetToken $passwordResetToken)
 {
     Mail::queue('emails.reset_password_info', ['user' => $user, 'passwordResetToken' => $passwordResetToken, 'link' => $passwordResetToken->getResetPasswordLink()], function ($message) use($user, $passwordResetToken) {
         $transParams = array_dot($user->toArray());
         $transParams['app_name'] = trans('base.app.name');
         $message->to($passwordResetToken->email, $user->username)->subject(trans('reset_password.request_code.email.subject', $transParams));
     });
 }
开发者ID:practicegeniusci,项目名称:DemoApp,代码行数:8,代码来源:UserNotifier.php

示例3: fillFromEloquent

 public function fillFromEloquent(User $user)
 {
     $this->eloquent = $user;
     $attributes = $user->toArray();
     if (isset($this->username)) {
         unset($attributes['username']);
     }
     $this->fill($attributes);
 }
开发者ID:CupOfTea696,项目名称:CardsAgainstTea,代码行数:9,代码来源:OnlineUser.php

示例4: transform

 public function transform(User $user)
 {
     return $user->toArray();
 }
开发者ID:Vagabondtq,项目名称:lumen-api-demo,代码行数:4,代码来源:UserTransformer.php

示例5: generateUserToken

 /**
  * Generate a jwt token for user
  * @param User $user
  * @param bool $rememberMe
  * @param bool $jwtCookie
  * @return string
  */
 public function generateUserToken($user, $rememberMe = false, $jwtCookie = false)
 {
     $data = ["sub" => (int) $user->id, "user" => $user->toArray(), "rememberMe" => (int) $rememberMe, "auth" => $this->calculateAuthHash($user)];
     // compute exp
     $ttl = $rememberMe ? $this->ttlRememberMe : $this->ttl;
     $data["exp"] = is_string($ttl) ? strtotime($ttl) : time() + $ttl;
     // compute csrf if using cookie
     if ($jwtCookie) {
         $data["csrf"] = $this->request->getCsrfToken();
     }
     $token = $this->encode($data);
     if ($jwtCookie) {
         $this->addCookieToken($this->tokenParam, $token, $data["exp"]);
     }
     return $token;
 }
开发者ID:amnah,项目名称:yii2-angular,代码行数:23,代码来源:JwtAuth.php

示例6: 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());
     }
 }
开发者ID:erickmo,项目名称:CapcusAPI,代码行数:62,代码来源:UserAPI.php


注:本文中的app\models\User::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。