44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?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']}");
|
|
}
|
|
}
|
|
}
|
|
}
|