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


PHP User::toArray方法代码示例

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


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

示例1: transform

 public function transform(User $user = null)
 {
     if (!$user) {
         return null;
     }
     return $user->toArray();
 }
开发者ID:jorzhikgit,项目名称:laravel-angular-base,代码行数:7,代码来源:UserTransformer.php

示例2: authenticated

 /**
  * Send the response after the user was authenticated.
  *
  * @see https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L114
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \App\User  $user
  * @return \Illuminate\Http\Response
  */
 protected function authenticated(Request $request, User $user)
 {
     if ($request->wantsJson() || $request->ajax()) {
         return response()->json($user->toArray(), 200);
     } else {
         return redirect()->intended($this->redirectPath());
     }
 }
开发者ID:santakani,项目名称:santakani.com,代码行数:17,代码来源:AuthController.php

示例3: transform

 /**
  * Transform object into a generic array
  *
  * @var  object
  */
 public function transform(\App\User $user)
 {
     $data = $user->toArray();
     unset($data['dob']);
     unset($data['gender']);
     unset($data['pivot']);
     return $data;
 }
开发者ID:simmatrix,项目名称:MMUCRS,代码行数:13,代码来源:AdminTransformer.php

示例4: insertUserSocialData

 public function insertUserSocialData($user_data)
 {
     $user = new User();
     $user->name = $user_data->name;
     $user->email = $user_data->email;
     $user->social_id = $user_data->token;
     $user->user_type = 1;
     $user->active = 1;
     if ($user->save()) {
         return $user->toArray();
     }
     return "";
 }
开发者ID:Incubasys,项目名称:sql_query_help,代码行数:13,代码来源:User.php

示例5: logBuy

 /**
  * log the buy
  *
  * @param  $user \App\User
  * @param  $offer \App\Offer
  * @return Response             the image download
  */
 public function logBuy(User $user, Offer $offer)
 {
     if ($user->toArray() == [] || $offer->toArray() == []) {
         \App::abort(404, 'The API doesn\'t exist');
     }
     $userRepo = new UserRepository($user);
     $userRepo->logBuy($offer);
     return json_encode(["points" => $userRepo->getUserPoints(), "level" => $userRepo->getUserLevel()->id]);
 }
开发者ID:TeamAppEngine,项目名称:adraaf.server,代码行数:16,代码来源:UsersController.php

示例6: function

    });
    Route::get('messages', ['uses' => 'MessageController@index', 'as' => 'all-messages', 'middleware' => 'oauth:administrator']);
    Route::post('messages/{id}/accept', ['uses' => 'MessageController@acceptMessage', 'as' => 'accept-message', 'middleware' => 'oauth:administrator']);
    Route::post('messages/{id}/reject', ['uses' => 'MessageController@rejectMessage', 'as' => 'reject-message', 'middleware' => 'oauth:administrator']);
});
// Create an administrator
Route::post('create-admin', function () {
    $user = new User();
    $validator = Validator::make(request()->all(), ['username' => 'required|unique:users|max:20', 'password' => 'required', 'email' => 'required|unique:users|max:30']);
    if ($validator->fails()) {
        return response()->json(['success' => false, 'message' => 'Validation Failed', 'errors' => $validator->errors()->all()], 422);
    }
    $user->username = request()->get('username');
    $user->password = Hash::make(request()->get('password'));
    $user->email = request()->get('email');
    $user->save();
    return response()->json(['success' => true, 'message' => 'Administrator created', 'resource' => $user->toArray()]);
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
    //
});
开发者ID:aninditkarmakar,项目名称:salmu-desi,代码行数:31,代码来源:routes.php

示例7: handleFacebookCallback

 /**
  * Obtain the user information from Facebook.
  *
  * @return Response
  */
 public function handleFacebookCallback()
 {
     $user = Socialite::driver('facebook')->user();
     //dd($user);
     if (User::where('email', $user->email)->where('social', true)->count()) {
         Auth::login(User::where('email', '=', $user->email)->first());
         return redirect('profile')->with('success', 'Welcome ' . $user->name);
     } else {
         echo "auth no attempt matched";
         $row = new User();
         $row->email = $user->email;
         $row->avatar = $user->avatar;
         $row->name = $user->name;
         //$row->firstname = $user->user['first_name'];
         //$row->lastname = $user->user['last_name'];
         $row->social = true;
         $row->active = true;
         $row->password = bcrypt(str_random(40));
         if ($row->save()) {
             Mail::send('emails.welcome', $row->toArray(), function ($message) use($row) {
                 $message->from('no-reply@tattoocultr.com', "Tattoo Cultr");
                 $message->subject("Welcome to Tattoo Cultr");
                 $message->to($row['email']);
             });
             return redirect('user/login/facebook')->with('success', 'Registration successful!! Please complete your profile');
         } else {
             return redirect('profile')->with('error', 'Error in Signing up. Please try again later..');
         }
     }
 }
开发者ID:erabhidhaliwal,项目名称:oottatcultr,代码行数:35,代码来源:AuthController.php

示例8: signup

 /**
  * Create Email and Password Account.
  */
 public function signup(Request $request)
 {
     $validator = Validator::make($request->all(), ['displayName' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required']);
     if ($validator->fails()) {
         return response()->json(['message' => $validator->messages()], 400);
     }
     $img = DefaultProfileImage::create($request->input('displayName'));
     $imageName = uniqid();
     $imgFile = public_path('uploads') . "/" . $imageName . '.png';
     $image = Image::make($img->encode());
     $image->save($imgFile, 100);
     $user = new User();
     $user->displayName = $request->input('displayName');
     $user->email = $request->input('email');
     $user->password = Hash::make($request->input('password'));
     $user->image = $imageName . '.png';
     $user->activation_code = $random_hash = md5(uniqid(rand(), true));
     $user->save();
     $role = Role::where('name', 'user')->first();
     $user->roles()->attach($role);
     $user_arr = $user->toArray();
     Mail::send("emails.welcome", $user_arr, function ($message) use($user_arr) {
         $message->from('no-reply@art.com', "Site Name");
         $message->subject('Welcome to site name');
         $message->to($user_arr['email']);
     });
     //return response()->json(['token' => $this->createToken($user)]);
     return response()->json(["message" => "User created. We send a confirmation email. Check your email account.", 'token' => $this->createToken($user)]);
 }
开发者ID:8secs,项目名称:smartSystem,代码行数:32,代码来源:AuthController.php

示例9: askUserToConnectAccountToProfile

 /**
  * If email from service already exists in database ask user
  * to connect that account to the service he's trying to log in
  * with by entering accounts password or authenticating with
  * one of the services that account is already attached to
  *
  * @param User $user
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function askUserToConnectAccountToProfile($user)
 {
     Session::put('account', $user->toArray());
     return response()->json(['code' => $user->password ? 1 : 2, 'message' => trans('app.userWithEmailExists')], 422);
 }
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:14,代码来源:Oauth.php


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