當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。