当前位置: 首页>>代码示例>>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;未经允许,请勿转载。