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


PHP Spark::user方法代码示例

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


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

示例1: current

 /**
  * Get the current discount for the given user.
  *
  * @param  Request  $request
  * @param  string  $userId
  * @return Response
  */
 public function current(Request $request, $userId)
 {
     $user = Spark::user()->where('id', $userId)->firstOrFail();
     if ($coupon = $this->coupons->forBillable($user)) {
         return response()->json($coupon->toArray());
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:14,代码来源:CouponController.php

示例2: store

 /**
  * Create a discount for the given user.
  *
  * @param  Request  $request
  * @param  string  $userId
  * @return Response
  */
 public function store(Request $request, $userId)
 {
     $user = Spark::user()->where('id', $userId)->firstOrFail();
     $this->validate($request, ['type' => 'required|in:amount,percent', 'value' => 'required|integer', 'duration' => 'required|in:once,forever,repeating', 'months' => 'required_if:duration,repeating']);
     $coupon = StripeCoupon::create(['currency' => 'usd', 'amount_off' => $request->type == 'amount' ? $request->value * 100 : null, 'percent_off' => $request->type == 'percent' ? $request->value : null, 'duration' => $request->duration, 'duration_in_months' => $request->months, 'max_redemptions' => 1], config('services.stripe.secret'));
     $user->applyCoupon($coupon->id);
 }
开发者ID:defenestrator,项目名称:groid,代码行数:14,代码来源:DiscountController.php

示例3: getCurrentUser

 /**
  * Get the current user of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCurrentUser()
 {
     $user = Spark::user();
     if (Spark::usingTeams()) {
         $user->currentTeam;
     }
     return $user->withHidden(['last_four', 'extra_billing_info']);
 }
开发者ID:mastashake08,项目名称:laravel-spark-archive,代码行数:13,代码来源:UserRepository.php

示例4: handle

 /**
  * {@inheritdoc}
  */
 public function handle($team, $email)
 {
     $invitedUser = Spark::user()->where('email', $email)->first();
     $this->emailInvitation($invitation = $this->createInvitation($team, $email, $invitedUser));
     if ($invitedUser) {
         event(new UserInvitedToTeam($team, $invitedUser));
     }
     return $invitation;
 }
开发者ID:defenestrator,项目名称:groid,代码行数:12,代码来源:SendInvitation.php

示例5: getCurrentUser

 /**
  * Get the current user of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCurrentUser()
 {
     $user = Spark::user();
     if (Spark::usingTeams()) {
         $user->currentTeam;
     }
     $user->subscriptions;
     return $user->withHidden(['card_brand', 'card_last_four', 'extra_billing_info']);
 }
开发者ID:mzkmzk,项目名称:spark,代码行数:14,代码来源:UserRepository.php

示例6: stopImpersonating

 /**
  * Stop impersonating and switch back to primary account.
  *
  * @param  Request  $request
  * @return Response
  */
 public function stopImpersonating(Request $request)
 {
     $currentId = Auth::id();
     // We will make sure we have an impersonator's user ID in the session and if the
     // value doesn't exist in the session we will log this user out of the system
     // since they aren't really impersonating anyone and manually hit this URL.
     if (!$request->session()->has('spark:impersonator')) {
         Auth::logout();
         return redirect('/');
     }
     $userId = $request->session()->pull('spark:impersonator');
     // After removing the impersonator user's ID from the session so we can retrieve
     // the original user. Then, we will flush the entire session to clear out any
     // stale data from while we were doing the impersonation of the other user.
     $request->session()->flush();
     Auth::login(Spark::user()->findOrFail($userId));
     return redirect('/spark/kiosk#/users/' . $currentId);
 }
开发者ID:defenestrator,项目名称:groid,代码行数:24,代码来源:ImpersonationController.php

示例7: login

 /**
  * Login via the emergency token.
  *
  * @param  Request  $request
  * @return Response
  */
 public function login(Request $request)
 {
     $this->validate($request, ['token' => 'required']);
     // If there is no authentication ID stored in the session, it means that the user
     // hasn't made it through the login screen so we'll just redirect them back to
     // the login view. They must have hit the route manually via a specific URL.
     if (!$request->session()->has('spark:auth:id')) {
         return redirect('login');
     }
     $user = Spark::user()->findOrFail($request->session()->pull('spark:auth:id'));
     // Here we will check this hash of the token against the stored hash of the reset
     // token to make sure they match. If they don't match then the emergency token
     // is invalid so we'll redirect back out with an error message for the user.
     $resetCode = $user->two_factor_reset_code;
     if (!Hash::check($request->token, $resetCode)) {
         return redirect('login')->withErrors(['token' => 'The emergency token was invalid.']);
     }
     // If the token was valid we will login this user after disabling the two-factor
     // authentication settings so that they don't get stuck again. They will then
     // re-enable two-factor authentication in their settings if they so choose.
     $this->disableTwoFactorAuth($user);
     Auth::login($user, $request->session()->pull('spark:auth:remember', false));
     return redirect()->intended($this->redirectPath());
 }
开发者ID:defenestrator,项目名称:groid,代码行数:30,代码来源:EmergencyLoginController.php

示例8: trialUsers

 /**
  * Get the number of users who are on a generic trial.
  *
  * @return Response
  */
 public function trialUsers()
 {
     return Spark::user()->where('trial_ends_at', '>=', Carbon::now())->count();
 }
开发者ID:defenestrator,项目名称:groid,代码行数:9,代码来源:PerformanceIndicatorsController.php

示例9: verifyToken

 /**
  * Verify the given authentication token.
  *
  * @param  Request  $request
  * @return Response
  */
 public function verifyToken(Request $request)
 {
     $this->validate($request, ['token' => 'required']);
     // If there is no authentication ID stored in the session, it means that the user
     // hasn't made it through the login screen so we'll just redirect them back to
     // the login view. They must have hit the route manually via a specific URL.
     if (!$request->session()->has('spark:auth:id')) {
         return redirect('login');
     }
     $user = Spark::user()->findOrFail($request->session()->pull('spark:auth:id'));
     // Next, we'll verify the actual token with our two-factor authentication service
     // to see if the token is valid. If it is, we can login the user and send them
     // to their intended location within the protected part of this application.
     if (Spark::interact(Verify::class, [$user, $request->token])) {
         Auth::login($user, $request->session()->pull('spark:auth:remember', false));
         return redirect()->intended($this->redirectPath());
     } else {
         return back();
     }
 }
开发者ID:defenestrator,项目名称:groid,代码行数:26,代码来源:LoginController.php

示例10: create

 /**
  * {@inheritdoc}
  */
 public function create(array $data)
 {
     $user = Spark::user();
     $user->forceFill(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'last_read_announcements_at' => Carbon::now(), 'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays())])->save();
     return $user;
 }
开发者ID:defenestrator,项目名称:groid,代码行数:9,代码来源:UserRepository.php


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