• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP app\User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('[email protected]')->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


示例16: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $newUser = new User();
     $newUser->email = '[email protected]';
     $newUser->password = Hash::make('password');
     $newUser->save();
 }
开发者ID:rob-meh,项目名称:weddinger,代码行数:12,代码来源:UserSeeder.php


示例17: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|string', 'email' => 'required|email|unique:users,email', 'twitter_username' => 'string', 'password' => 'required|confirmed|string', 'password_confirmation' => 'required|string']);
     if ($validator->fails()) {
         $httpStatus = 400;
         $outcome = 'no';
         $error = $validator->errors()->all();
     } else {
         $newuser = new User();
         $newuser->name = $request->name;
         $newuser->email = $request->email;
         $newuser->activateToken = uniqid();
         $newuser->twitter_username = !is_null($request->twitter_username) ? $request->twitter_username : "";
         $newuser->password = bcrypt($request->password);
         $newuser->save();
         Mail::send('emails.activate', ['user' => $newuser], function ($message) use($newuser) {
             $message->subject("Welcome, activate your account in Saveet");
             $message->to($newuser->email);
         });
         $httpStatus = 200;
         $outcome = 'yes';
         $error = '';
     }
     return response()->api($httpStatus, $outcome, $error, '');
 }
开发者ID:jlightyear,项目名称:bootcampinc,代码行数:30,代码来源:UserController.php


示例18: destroy

 /**
  * Determine if the given user can delete the given settings.
  *
  * @param User $user
  * @param Settings $settings
  *
  * @return bool
  */
 public function destroy(User $user, Setting $settings)
 {
     if ($user->canDo('settings.setting.delete')) {
         return true;
     }
     return $user->id === $settings->user_id;
 }
开发者ID:lavalite,项目名称:settings,代码行数:15,代码来源:SettingPolicy.php


示例19: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(User $user)
 {
     $users = $user->getUsers(['Author', '3rd party content provider', 'Administrator', 'Publisher', 'Frontpage editor', 'Super Admin'], 'name|asc');
     $user_names = array();
     $i = 0;
     foreach ($users as $user) {
         foreach ($user->details as $u) {
             $user_names[$user->name] = $u->full_name;
         }
         $i++;
     }
     $users = array_name($user_names);
     $auth = Auth::user()->hasRole('Author', '') ? Auth::user()->name : null;
     $image_gallery = [['img' => null, 'title' => null, 'alt' => null, 'source' => null, 'author' => null, 'meta_desc' => null, 'meta_key' => null]];
     if (count(Session::get('_old_input')['image']) > 0) {
         $image_gallery = '';
         $image_gallery = add_image_array(Session::get('_old_input')['image']);
     }
     $checked_cats = '';
     $catid = '';
     $json_extra = '';
     if (count(Session::get('_old_input')['cat']) > 0) {
         $checked_cats = join(',', Session::get('_old_input')['cat']);
     }
     $extra_fields = '';
     if (count(Session::get('_old_input')['extra_fields']) > 0) {
         $extra_fields = Session::get('_old_input')['extra_fields'];
         $json_extra = json_encode($extra_fields);
     }
     $fields = hasFields([2], ['select' => ['col-sm' => 5], 'input' => ['col-sm' => 5], 'textarea' => ['col-sm' => 9]], $extra_fields);
     return view('admin.articles.create', compact('users', 'auth', 'fields', 'image_gallery', 'checked_cats', 'catid', 'json_extra', 'extra_fields'));
 }
开发者ID:Vatia13,项目名称:gbtimes,代码行数:37,代码来源:ArticlesController.php


示例20: save

 private function save(User $user, array $inputs)
 {
     $user->name = $inputs['name'];
     $user->email = $inputs['email'];
     $user->admin = isset($inputs['admin']);
     $user->save();
 }
开发者ID:py1903,项目名称:My-Blog-Creator,代码行数:7,代码来源:UserRepository.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP assets\AppAsset类代码示例发布时间:2022-05-23
下一篇:
PHP app\Topic类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap