Closed vmiguellima closed 3 years ago
@vmiguellima This seems like a great feature. I'll look into this in the upcoming days. 😁
@rennokki I really enjoy this package! Is there any way I can help?
Other thing that I would do is to add the following migrations:
add_team_id_column_to_subscriptions_table
and add_customers_columns_to_teams_table
add_team_id_column_to_subscriptions_table
:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTeamIdColumnToSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->unsignedBigInteger('team_id')->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->dropColumn('team_id');
});
}
}
Table add_customers_columns_to_teams_table
:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCustomersColumnsToTeamsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('teams', function (Blueprint $table) {
$table->string('stripe_id')->nullable()->index();
$table->string('card_brand')->nullable();
$table->string('card_last_four', 4)->nullable();
$table->timestamp('trial_ends_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('teams', function (Blueprint $table) {
$table->dropColumn([
'stripe_id',
'card_brand',
'card_last_four',
'trial_ends_at',
]);
});
}
}
So we can easily use team as our billable model (as showed in docs):
BillingPortal::setBillableOnRequest(function (Request $request) {
return $request->user()->currentTeam;
});
This issue has been automatically closed because it has not had any recent activity. 😨
@rennokki Congrats on this Amazing Package!
Is there any way to prevent user from upgrade downgrade at any time?