Update
This commit is contained in:
43
database/seeders/PlanSeeder.php
Normal file
43
database/seeders/PlanSeeder.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PlanSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$plans = config('platform.purchases.subscriptions');
|
||||
|
||||
foreach ($plans as $plan) {
|
||||
|
||||
if ($plan['type'] !== 'subscription_plans') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if plan with this tier already exists
|
||||
$existingPlan = DB::table('plans')
|
||||
->where('tier', $plan['id'])
|
||||
->first();
|
||||
|
||||
if (! $existingPlan) {
|
||||
DB::table('plans')->insert([
|
||||
'name' => $plan['name'],
|
||||
'tier' => $plan['id'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->command->info("Inserted plan: {$plan['name']}");
|
||||
} else {
|
||||
$this->command->info("Skipped existing plan tier: {$plan['id']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user