40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Phinx\Seed\AbstractSeed;
|
|
|
|
/**
|
|
* Inserisce due piani base d'esempio.
|
|
* I prezzi/nome sono modificabili poi dal pannello admin o ri-eseguendo il seed.
|
|
* stripe_price_id resta NULL: lo popoleremo quando colleghiamo Stripe.
|
|
*/
|
|
class SubscriptionPlansSeeder extends AbstractSeed
|
|
{
|
|
public function run(): void
|
|
{
|
|
// Evita duplicati se il seed viene rilanciato: inserisce solo se la tabella è vuota
|
|
$count = (int)$this->fetchRow("SELECT COUNT(*) AS c FROM subscription_plans")['c'];
|
|
if ($count > 0) {
|
|
return;
|
|
}
|
|
|
|
$data = [
|
|
[
|
|
'name' => 'Base',
|
|
'description' => 'Prenotazioni online, agenda e gestione clienti.',
|
|
'price' => 19.90,
|
|
'billing_period' => 'monthly',
|
|
'is_active' => 1,
|
|
],
|
|
[
|
|
'name' => 'Pro',
|
|
'description' => 'Tutto del piano Base + più staff, statistiche e priorità in ricerca.',
|
|
'price' => 39.90,
|
|
'billing_period' => 'monthly',
|
|
'is_active' => 1,
|
|
],
|
|
];
|
|
|
|
$this->table('subscription_plans')->insert($data)->saveData();
|
|
}
|
|
}
|