- Criar tabela plans com Free, Pro Monthly, Pro Annual - Criar tabela subscriptions com status e integração PayPal - Criar tabela invoices com numeração sequencial WM-YYYY-NNNNNN - Models: Plan, Subscription, Invoice com helpers - User: hasActiveSubscription(), onTrial(), currentPlan(), etc. - API: GET /api/plans (público) - Seeder: PlansSeeder com 3 planos base - Fase 2 do roadmap SaaS concluída
137 lines
4.6 KiB
PHP
137 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Plan;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class PlansSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Free Plan
|
|
Plan::updateOrCreate(
|
|
['slug' => 'free'],
|
|
[
|
|
'name' => 'Free',
|
|
'description' => 'Perfecto para empezar a controlar tus finanzas personales',
|
|
'price' => 0,
|
|
'currency' => 'EUR',
|
|
'billing_period' => 'free',
|
|
'trial_days' => 0,
|
|
'features' => [
|
|
'Hasta 3 cuentas bancarias',
|
|
'Hasta 10 categorías',
|
|
'Dashboard básico',
|
|
'Importar transacciones (CSV)',
|
|
'Detección de duplicados',
|
|
'Soporte por email',
|
|
],
|
|
'limits' => [
|
|
'accounts' => 3,
|
|
'categories' => 10,
|
|
'budgets' => 3,
|
|
'goals' => 1,
|
|
'reports' => false,
|
|
'recurring' => false,
|
|
'api_access' => false,
|
|
],
|
|
'is_active' => true,
|
|
'is_featured' => false,
|
|
'sort_order' => 1,
|
|
]
|
|
);
|
|
|
|
// Pro Monthly
|
|
Plan::updateOrCreate(
|
|
['slug' => 'pro-monthly'],
|
|
[
|
|
'name' => 'Pro Mensual',
|
|
'description' => 'Todas las funcionalidades para control financiero completo',
|
|
'price' => 9.99,
|
|
'currency' => 'EUR',
|
|
'billing_period' => 'monthly',
|
|
'trial_days' => 7,
|
|
'features' => [
|
|
'Cuentas bancarias ilimitadas',
|
|
'Categorías ilimitadas',
|
|
'Dashboard avanzado',
|
|
'Presupuestos ilimitados',
|
|
'Metas financieras ilimitadas',
|
|
'Transacciones recurrentes',
|
|
'Informes detallados',
|
|
'Exportar a Excel/PDF',
|
|
'Notificaciones por email',
|
|
'Notificaciones WhatsApp',
|
|
'Módulo de negocios',
|
|
'Soporte prioritario',
|
|
],
|
|
'limits' => [
|
|
'accounts' => null, // unlimited
|
|
'categories' => null,
|
|
'budgets' => null,
|
|
'goals' => null,
|
|
'reports' => true,
|
|
'recurring' => true,
|
|
'api_access' => true,
|
|
'business_module' => true,
|
|
],
|
|
'is_active' => true,
|
|
'is_featured' => true,
|
|
'sort_order' => 2,
|
|
]
|
|
);
|
|
|
|
// Pro Annual
|
|
Plan::updateOrCreate(
|
|
['slug' => 'pro-annual'],
|
|
[
|
|
'name' => 'Pro Anual',
|
|
'description' => 'Ahorra 2 meses con el plan anual - ¡Mejor valor!',
|
|
'price' => 99.99,
|
|
'currency' => 'EUR',
|
|
'billing_period' => 'annual',
|
|
'trial_days' => 7,
|
|
'features' => [
|
|
'Todo lo de Pro Mensual',
|
|
'¡Ahorra 17% vs mensual!',
|
|
'Cuentas bancarias ilimitadas',
|
|
'Categorías ilimitadas',
|
|
'Dashboard avanzado',
|
|
'Presupuestos ilimitados',
|
|
'Metas financieras ilimitadas',
|
|
'Transacciones recurrentes',
|
|
'Informes detallados',
|
|
'Exportar a Excel/PDF',
|
|
'Notificaciones por email',
|
|
'Notificaciones WhatsApp',
|
|
'Módulo de negocios',
|
|
'Soporte prioritario',
|
|
],
|
|
'limits' => [
|
|
'accounts' => null,
|
|
'categories' => null,
|
|
'budgets' => null,
|
|
'goals' => null,
|
|
'reports' => true,
|
|
'recurring' => true,
|
|
'api_access' => true,
|
|
'business_module' => true,
|
|
],
|
|
'is_active' => true,
|
|
'is_featured' => false,
|
|
'sort_order' => 3,
|
|
]
|
|
);
|
|
|
|
$this->command->info('Plans seeded successfully!');
|
|
$this->command->table(
|
|
['Slug', 'Name', 'Price', 'Billing'],
|
|
Plan::orderBy('sort_order')->get(['slug', 'name', 'price', 'billing_period'])->toArray()
|
|
);
|
|
}
|
|
}
|