本文整理汇总了PHP中Laravel\Spark\Spark::interact方法的典型用法代码示例。如果您正苦于以下问题:PHP Spark::interact方法的具体用法?PHP Spark::interact怎么用?PHP Spark::interact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Spark\Spark
的用法示例。
在下文中一共展示了Spark::interact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: baseValidator
/**
* Get the base validator instance for a register request.
*
* @return \Illuminate\Validation\Validator
*/
public function baseValidator()
{
$validator = Spark::interact(CreateUser::class . '@validator', [$this]);
$validator->sometimes('plan', 'required|in:' . Spark::activePlanIdList(), function () {
return Spark::needsCardUpFront();
});
return $validator;
}
示例2: subscribe
/**
* Subscribe the given user to a subscription plan.
*
* @param RegisterRequest $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \Illuminate\Contracts\Auth\Authenticatable
*/
protected function subscribe($request, $user)
{
if (!$request->hasPaidPlan()) {
return $user;
}
Spark::interact(Subscribe::class, [$user, $request->plan(), true, $request->all()]);
return $user;
}
示例3: interaction
/**
* Execute the given interaction.
*
* This performs the common validate and handle flow of some interactions.
*
* @param Request $request
* @param string $interaction
* @param array $parameters
* @return void
*/
public function interaction(Request $request, $interaction, array $parameters)
{
$validator = Spark::interact($interaction . '@validator', $parameters);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
return Spark::interact($interaction, $parameters);
}
示例4: show
/**
* Get the team matching the given ID.
*
* @param Request $request
* @param string $teamId
* @return Response
*/
public function show(Request $request, $teamId)
{
$team = Spark::interact(TeamRepository::class . '@find', [$teamId]);
abort_unless($request->user()->onTeam($team), 404);
if ($request->user()->ownsTeam($team)) {
$team->load('subscriptions');
$team->shouldHaveOwnerVisibility();
}
return $team;
}
示例5: redeem
/**
* Redeem the given coupon code.
*
* @param Request $request
* @return Response
*/
public function redeem(Request $request)
{
$this->validate($request, ['coupon' => 'required']);
// We will verify that the coupon can actually be redeemed. In some cases even
// valid coupons can not get redeemed by an existing user if this coupon is
// running as a promotion for brand new registrations to the application.
if (!$this->coupons->canBeRedeemed($request->coupon)) {
return response()->json(['coupon' => ['This coupon code is invalid.']], 422);
}
Spark::interact(RedeemCoupon::class, [$request->user(), $request->coupon]);
}
示例6: disable
/**
* Disable two-factor authentication for the user.
*
* @param Request $request
* @return Response
*/
public function disable(Request $request)
{
Spark::interact(DisableTwoFactorAuth::class, [$request->user()]);
$request->user()->forceFill(['uses_two_factor_auth' => false])->save();
}
示例7: handle
/**
* {@inheritdoc}
*/
public function handle($user, array $data)
{
event(new TeamCreated($team = Spark::interact(TeamRepository::class . '@create', [$user, $data])));
Spark::interact(AddTeamMemberContract::class, [$team, $user, 'owner']);
return $team;
}
示例8: store
/**
* Create the subscription for the team.
*
* @param CreateSubscriptionRequest $request
* @param Team $team
* @return Response
*/
public function store(CreateSubscriptionRequest $request, Team $team)
{
Spark::interact(SubscribeTeam::class, [$team, $request->plan(), $request->all()]);
}
示例9: currentTeam
/**
* Get the current team for the user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \Laravel\Spark\Team|null
*/
protected function currentTeam($user)
{
if (Spark::usesTeams() && $user->currentTeam()) {
return Spark::interact(TeamRepository::class . '@find', [$user->currentTeam()->id]);
}
}
示例10: accept
/**
* Accept the given invitations.
*
* @param Request $request
* @param \Laravel\Spark\Invitation $invitation
* @return Response
*/
public function accept(Request $request, Invitation $invitation)
{
abort_unless($request->user()->id == $invitation->user_id, 404);
Spark::interact(AddTeamMember::class, [$invitation->team, $request->user()]);
$invitation->delete();
}
示例11: store
/**
* Create a new invitation.
*
* @param CreateInvitationRequest $request
* @param \Laravel\Spark\Team $team
* @return Response
*/
public function store(CreateInvitationRequest $request, $team)
{
Spark::interact(SendInvitation::class, [$team, $request->email]);
}
示例12: handle
/**
* {@inheritdoc}
*/
public function handle($request)
{
return Spark::interact(UserRepository::class . '@create', [$request->all()]);
}
示例13: store
/**
* Create the subscription for the user.
*
* @param CreateSubscriptionRequest $request
* @return Response
*/
public function store(CreateSubscriptionRequest $request)
{
$plan = Spark::plans()->where('id', $request->plan)->first();
Spark::interact(Subscribe::class, [$request->user(), $plan, false, $request->all()]);
}
示例14: disableTwoFactorAuth
/**
* Disable two-factor authentication for the given user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
protected function disableTwoFactorAuth($user)
{
Spark::interact(DisableTwoFactorAuth::class, [$user]);
$user->forceFill(['uses_two_factor_auth' => false])->save();
}
示例15: update
/**
* Update the payment method for the user.
*
* @param UpdatePaymentMethodRequest $request
* @return Response
*/
public function update(UpdatePaymentMethodRequest $request)
{
Spark::interact(UpdatePaymentMethod::class, [$request->user(), $request->all()]);
}