當前位置: 首頁>>代碼示例>>PHP>>正文


PHP app\User類代碼示例

本文整理匯總了PHP中app\User的典型用法代碼示例。如果您正苦於以下問題:PHP User類的具體用法?PHP User怎麽用?PHP User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: facebook

 public function facebook(Request $request)
 {
     $accessTokenUrl = 'https://graph.facebook.com/v2.5/oauth/access_token';
     $graphApiUrl = 'https://graph.facebook.com/v2.5/me';
     $params = ['code' => $request->input('code'), 'client_id' => $request->input('clientId'), 'redirect_uri' => $request->input('redirectUri'), 'client_secret' => '76cd1014c10586c33f3e13f03929a221'];
     $client = new \GuzzleHttp\Client();
     // Step 1. Exchange authorization code for access token.
     $accessToken = json_decode($client->get($accessTokenUrl, ['query' => $params])->getBody(), true);
     // Step 2. Retrieve profile information about the current user.
     $profile = json_decode($client->get($graphApiUrl, ['query' => $accessToken])->getBody(), true);
     // Step 3a. If user is already signed in then link accounts.
     if ($request->header('Authorization')) {
         $user = User::where('facebook', '=', $profile['id']);
         if ($user->first()) {
             return response()->json(['message' => 'There is already a Facebook account that belongs to you'], 409);
         }
         $token = explode(' ', $request->header('Authorization'))[1];
         $payload = (array) JWT::decode($token, Config::get('jwt.secret'), array('HS256'));
         $user = User::find($payload['sub']);
         $user->facebook = $profile['id'];
         $user->displayName = $user->displayName ?: $profile['name'];
         $user->save();
         return response()->json(['token' => $this->createToken($user)]);
     } else {
         $user = User::where('facebook', '=', $profile['id']);
         if ($user->first()) {
             return response()->json(['token' => $this->createToken($user->first())]);
         }
         $user = new User();
         $user->facebook = $profile['id'];
         $user->displayName = $profile['name'];
         $user->save();
         return response()->json(['token' => $this->createToken($user)]);
     }
 }
開發者ID:theprog,項目名稱:election-hacakthon-cityzen,代碼行數:35,代碼來源:AuthenticateController.php

示例2: transform

 public function transform(User $user = null)
 {
     if (!$user) {
         return null;
     }
     return $user->toArray();
 }
開發者ID:jorzhikgit,項目名稱:laravel-angular-base,代碼行數:7,代碼來源:UserTransformer.php

示例3: __construct

 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($EcNa, $typ, $eml, $pass, $nomresp, $fix, $port, $adres, $ville, $pays)
 {
     $this->ecoleNom = $EcNa;
     $this->type = $typ;
     $this->email = $eml;
     $this->password = $pass;
     $this->nomResponsable = $nomresp;
     $this->fix = $fix;
     $this->portab = $port;
     $this->adresse = $adres;
     $this->ville = $ville;
     $this->pays = $pays;
     $user = new User();
     $user->name = $this->ecoleNom;
     $user->type = $this->type;
     $user->email = $this->email;
     $user->password = \Hash::make($this->password);
     $user->nom_responsable = $this->nomResponsable;
     $user->tel_fixe = $this->fix;
     $user->tel_portable = $this->portab;
     $user->adresse = $this->adresse;
     $user->ville = $this->ville;
     $user->pays = $this->pays;
     $user->save();
     if ($user) {
         $info = ['nom_resp' => $this->nomResponsable, 'nom_ecole' => $this->ecoleNom, 'email' => $this->email, 'pass' => $this->password];
         Mail::queue('emails.school', $info, function ($message) {
             $message->to($this->email, 'ok')->from('creche@gmail.com')->subject('Bienvenue  !');
         });
     }
 }
開發者ID:khaleader,項目名稱:creche,代碼行數:36,代碼來源:SchoolSendEmailEvent.php

示例4: select

 public function select(User $user)
 {
     $educations = $user->educations()->latest()->paginate(20);
     $infos = $user->info()->latest()->paginate(20);
     $bio = $user->biography()->first();
     return view('admin.users.management', compact('user', 'educations', 'infos', 'bio'))->with(['title' => $user->username]);
 }
開發者ID:emadmrz,項目名稱:Hawk,代碼行數:7,代碼來源:UserController.php

示例5: postStudent

 public function postStudent(StudentRequest $request)
 {
     $user = new User();
     $user->username = $request->txtten;
     $user->password = Hash::make($request->txtten);
     $user->name = $request->txtten;
     $user->save();
     $user_id = $user->id;
     $permission = Permission::where('slug', 'student')->get()->first();
     $permissionUser = new PermissionUser();
     $permissionUser->permission_id = $permission->id;
     $permissionUser->user_id = $user_id;
     $permissionUser->save();
     $student = new ThiSinh();
     $student->ten = $request->txtten;
     $student->gioitinh = $request->sltGt;
     $student->namsinh = $request->txtns;
     $student->quequan = $request->txtqq;
     $student->khuvuc = $request->txtkv;
     $student->user_id = $user_id;
     $student->save();
     $thisinh_id = $student->id;
     $point = new Diem();
     $point->sbd = $request->txtsbd;
     $point->mon1 = 0;
     $point->mon2 = 0;
     $point->mon3 = 0;
     $point->khoi = $request->txtkt;
     $point->thisinh_id = $thisinh_id;
     $point->save();
     return redirect()->route('cluster-staff.quan-ly-thong-tin-thi-sinh.listStudent')->with(['flash_level' => 'success', 'flash_message' => 'Success!!! Complete Add Student']);
 }
開發者ID:vjtc0n,項目名稱:project,代碼行數:32,代碼來源:ClusterStaffController.php

示例6: findByUserNameOrCreate

 public function findByUserNameOrCreate($userData)
 {
     $user = User::where('social_id', '=', $userData->id)->first();
     if (!$user) {
         $user = new User();
         $user->social_id = $userData->id;
         $user->email = $userData->email;
         $user->first_name = $userData->user['first_name'];
         $user->last_name = $userData->user['last_name'];
         $name = str_random(32);
         while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) {
             $name = str_random(32);
         }
         $filename = $name . '.' . 'jpg';
         Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename);
         Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename);
         $user->avatar = $filename;
         $user->gender = $userData->user['gender'];
         $user->verified = $userData->user['verified'];
         $user->save();
         \Session::put('auth_photo', $filename);
     } else {
         $this->checkIfUserNeedsUpdating($userData, $user);
         \Session::put('auth_photo', $user->avatar);
     }
     return $user;
 }
開發者ID:charlieboo,項目名稱:creatrip,代碼行數:27,代碼來源:UserRepository.php

示例7: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User(['name' => $data['name'], 'email' => $data['email'], 'image' => $data['image'], 'password' => bcrypt($data['password'])]);
     $user->role = 'user';
     $user->save();
     return $user;
 }
開發者ID:PacoFigueroa,項目名稱:loginlaravel,代碼行數:13,代碼來源:AuthController.php

示例8: destroy

 /**
  * Determine if the given user can delete the given resume.
  *
  * @param User $user
  * @param Resume $resume
  *
  * @return bool
  */
 public function destroy(User $user, Resume $resume)
 {
     if ($user->canDo('career.resume.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $resume->user_id;
 }
開發者ID:litecms,項目名稱:career,代碼行數:15,代碼來源:ResumePolicy.php

示例9: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User(['name' => $data['name'], 'last_name' => $data['last_name'], 'company' => $data['company'], 'number' => $data['number'], 'user' => $data['user'], 'password' => bcrypt($data['password']), 'email' => $data['email']]);
     $user->role = 'client';
     $user->save();
     return $user;
 }
開發者ID:briangdr,項目名稱:kargasW,代碼行數:13,代碼來源:AuthController.php

示例10: destroy

 /**
  * Determine if the given user can delete the given task.
  *
  * @param User $user
  * @param Task $task
  *
  * @return bool
  */
 public function destroy(User $user, Task $task)
 {
     if ($user->canDo('task.task.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $task->user_id;
 }
開發者ID:lavalite,項目名稱:task,代碼行數:15,代碼來源:TaskPolicy.php

示例11: test

 public function test()
 {
     $user = new User();
     $user->username = "test";
     $user->password = Hash::make("test");
     $user->save();
 }
開發者ID:FrozenDroid,項目名稱:dcapp,代碼行數:7,代碼來源:LoginController.php

示例12: destroy

 /**
  * Determine if the given user can delete the given pricelist.
  *
  * @param User $user
  * @param PriceList $pricelist
  *
  * @return bool
  */
 public function destroy(User $user, PriceList $pricelist)
 {
     if ($user->canDo('pricelist.pricelist.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $pricelist->user_id;
 }
開發者ID:litecms,項目名稱:pricelist,代碼行數:15,代碼來源:PriceListPolicy.php

示例13: register

 public static function register(array $data)
 {
     // Fake when saving data
     $user = new User();
     $user->fill(['name' => trim($data['name']), 'email' => filter_var($data['email'], FILTER_SANITIZE_EMAIL), 'password' => $data['password']]);
     return $user;
 }
開發者ID:rifkyekayama,項目名稱:laravel-5.1-broadcast-example,代碼行數:7,代碼來源:User.php

示例14: includeComments

 /**
  * Include comments.
  *
  * @param  \App\User                     $user
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeComments(User $user, ParamBag $params = null)
 {
     $transformer = new \App\Transformers\CommentTransformer($params);
     $parsed = $this->getParsedParams();
     $comments = $user->comments()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($comments, $transformer);
 }
開發者ID:linuxssm,項目名稱:l5essential,代碼行數:15,代碼來源:UserTransformer.php

示例15: UsersNewsFeed

 /**
  * Storing All Users Post
  * @return [type] [description]
  */
 public function UsersNewsFeed(NewsFeed $request, User $user)
 {
     //Ignore
     $newsFeed = $request->except('_token');
     //For NewsFeed
     $username = $request->input('UserPosting');
     $usernameUpdate = $request->input('UserNameBeingUpdated');
     //For Timelines
     $userID = $request->input('UserPostingID');
     // For Single User posting
     $id = Redis::incr('total_post_id');
     Redis::hset('list_post_id', $username, $id);
     Redis::lpush('newsFeed' . ':' . $username, json_encode($newsFeed));
     // Cross Users Posting
     if ($usernameUpdate == true) {
         Redis::lpush('newsFeed' . ':' . $usernameUpdate, json_encode($newsFeed));
     }
     /**
      * Minor Bug.
      * If someone (who you're not following) posts on your newsfeed it should also show up on your timeline also
      */
     // Timeline
     Redis::lpush('timeline' . ':' . $userID, json_encode($newsFeed));
     $faveID = $user->favoriteeList();
     // Users Following Timeline
     if ($faveID == true) {
         foreach ($faveID as $id) {
             Redis::lpush('timeline:' . $id, json_encode($newsFeed));
         }
     }
 }
開發者ID:Core-Tech-Labs,項目名稱:LAZ,代碼行數:35,代碼來源:BaseNewsFeed.php


注:本文中的app\User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。