Rotating Pricing Table for Laravel Spark
Can be placed anywhere, try it out on welcome.blade.php
###If you're using team plans
just swap out
$sparkPlans = Spark::plans();
with $sparkPlans = Spark::teamPlans();
var indentElements = $('[class*="tab-"]'); | |
$.each(indentElements, function (index) { | |
var indentAmount = parseInt(this.className.split('-')[1]); | |
var indentation = new Array(indentAmount + 1).join(' '); | |
this.innerHTML = indentation + this.innerHTML | |
}); |
Can be placed anywhere, try it out on welcome.blade.php
###If you're using team plans
just swap out
$sparkPlans = Spark::plans();
with $sparkPlans = Spark::teamPlans();
##Team Dropdown for Laravel Spark
Maybe you want a way for users to quickly jump to team settings?
Can be placed anywhere, try it out on user-right.blade.php
<?php $currentTeam = auth()->user()->currentTeam; ?>
If you want the ability to charge a team owner based on how many members their team has, like $10/user/month, then you utilize the Laravel Cashier functionality of incrementing the quantity.
You listen for when a new team member is added and you increase the quantity of the subscription by the amount of users and also listen for when a team member is removed to downsize charges. - Not Braintree Compatible
'Laravel\Spark\Events\Teams\TeamMemberAdded' => [
notification
Helper For Laravel SparkThe method assumes the current authenticated user, so you only need to pass the message
function notification($message)
{
$notification = app('Laravel\Spark\Contracts\Repositories\NotificationRepository');
return $notification->create(auth()->user(), $message);
@plan
Blade Directive For Laravel SparkWorks with user & team billing
Add this to the boot()
method of your AppServiceProvider
\Blade::directive('plan', function($plans) {
$model = auth()->user();
Makes 5 users each with 1 team that has 5 members
Add a team factory to database/factories/ModelFactory.php
$factory->define(App\Team::class, function (Faker\Generator $faker) {
return [
'name' => $faker->sentence,
add to your user model
public function teamMembers($role='member')
{
return $this->currentTeam
->users()
Makes it simple to use Spark's role feature on routes
Route::group(['middleware'=>'role:owner'], function(){
// owners only
});
Route::group(['middleware'=>'role:member'], function(){
Automatically limit your models to the current team
So you're using spark, and you have teams enabled. You start creating models and want to have them be team specific. Instead of writing, Model::where('team_id', auth()->user()->currentTeam->id)->get();
use this trait to add that behind the scenes so that every time you call on your model, it's assumed that you mean for the current team.
This assumes that the model has a team_id
, while it adds a scope of where team_id = currentTeam->id
.
Note: Implicit Route Model Binding in 5.2, auth session doesn't exist at the point of this trait causing issue. fixed in 5.3