▸ Webhooks point to /webhook/stripe or /webhook/braintree STRIPE_KEY= STRIPE_SECRET= BRAINTREE_ENV= BRAINTREE_MODEL= BRAINTREE_MERCHANT_ID= BRAINTREE_PUBLIC_KEY= BRAINTREE_SECRET_KEY=
=> ‘subscribed’ ], function () { // User must be subscribed to see this. }); Route::get(‘/team-paid’, [ ‘middleware’ => ‘teamSubscribed’ ], function () { // Team must be subscribed to see this. });
trialDays() from plan definition in SparkServiceProvider::booted() method ▸ Define plan // SparkServiceProvider::booted() Spark::plan(‘Basic’, ‘team-basic’) ->price(10) ->trialDays(10) ->features([ /* features */ ]); ▸ Warning! This behavior might be annoying for customers.
Subscription\UserSubscribed // And some team-specific events... Teams\Subscription\SubscriptionCancelled Teams\Subscription\SubscriptionUpdated Teams\Subscription\TeamSubscribed
__construct(NotificationRepository ($notifications) { $this->notifications = $notifications; } ▸ Then create a notification $this->notifications->create($user, [ ‘icon’ => ‘fa-users’, ‘body’ => ‘A team member completed a task!’, ‘action_text’ => ‘View Task’, ‘action_url’ => ‘/link/to/task’ ]); // This fires a Laravel\Spark\Events\NotificationCreated event
class ▸ Then, set the SparkChannel on the notification use Laravel\Spark\Notifications\SparkChannel; public function via($notifiable) { return [SparkChannel::class]; } php artisan make:notification TaskCompleted
Laravel\Spark\Notifications\SparkNotification; public function toSpark($notifiable) { return (new SparkNotification) ->action(‘View Task’, ‘/link/to/task’) ->icon(‘fa-users’) ->body(‘A team member completed a task!’); }
TaskCompleted); Notification::send($user, new TaskCompleted); // Notify all team members... $team->notify(new TaskCompleted); Notification::send($team, new TaskCompleted);
Laravel\Spark\User as SparkUser; class User extends SparkUser { use CanJoinTeams; } // SparkServiceProvider::booted() Spark::noAdditionalTeams(); // SparkServiceProvider::register() Spark::referToTeamAs(‘band’);
Iterate over each team... } if ($user->hasTeams()) { // The user belongs to at least one team... } if ($user->onTeam($team)) { // The user belongs to the given team... } if ($user->ownsTeam($team)) { // The user owns the given team... } foreach ($user->ownedTeams as $team) { // Iterate through all teams the user owns... } foreach ($user->invitations as $invitation) { // Iterate through all pending invitations for user... }
Is null if User does not belong to a Team ▸ Default behavior is to issue warning via VerifyUserHasTeam middleware echo $user->currentTeam->name; if ($user->currentTeam) { // Belongs to a team }
more roles // SparkServiceProvider::booted() Spark::useRoles([ ‘member’ => ‘Member’, ‘vip’ => ‘VIP’, ]); // Then you can do this if ($user->roleOn($team) === ‘vip’) { // This user is a VIP on the given team... }