webmoney/backend/app/Http/Controllers/Api/PlanController.php
marco 54cccdd095 refactor: migração para desenvolvimento direto no servidor
- Removido README.md padrão do Laravel (backend)
- Removidos scripts de deploy (não mais necessários)
- Atualizado copilot-instructions.md para novo fluxo
- Adicionada documentação de auditoria do servidor
- Sincronizado código de produção com repositório

Novo workflow:
- Trabalhamos diretamente em /root/webmoney (symlink para /var/www/webmoney)
- Mudanças PHP são instantâneas
- Mudanças React requerem 'npm run build'
- Commit após validação funcional
2025-12-19 11:45:32 +01:00

96 lines
3.3 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Plan;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class PlanController extends Controller
{
/**
* List all plans for pricing page (including coming soon)
*/
public function index(): JsonResponse
{
// Get active plans
$activePlans = Plan::active()->ordered()->get();
// Get coming soon plans (inactive but should be displayed)
$comingSoonPlans = Plan::where('is_active', false)
->whereIn('slug', ['business'])
->ordered()
->get();
$allPlans = $activePlans->merge($comingSoonPlans);
return response()->json([
'success' => true,
'data' => [
'plans' => $allPlans->map(function ($plan) {
return [
'id' => $plan->id,
'slug' => $plan->slug,
'name' => $plan->name,
'description' => $plan->description,
'price' => $plan->price,
'formatted_price' => $plan->formatted_price,
'monthly_price' => $plan->monthly_price,
'currency' => $plan->currency,
'billing_period' => $plan->billing_period,
'trial_days' => $plan->trial_days,
'features' => $plan->features,
'limits' => $plan->limits,
'is_free' => $plan->is_free,
'is_featured' => $plan->is_featured,
'is_active' => $plan->is_active,
'coming_soon' => !$plan->is_active,
'has_trial' => $plan->has_trial,
'savings_percent' => $plan->savings_percent,
];
}),
],
]);
}
/**
* Get a single plan by slug
*/
public function show(string $slug): JsonResponse
{
$plan = Plan::where('slug', $slug)->where('is_active', true)->first();
if (!$plan) {
return response()->json([
'success' => false,
'message' => 'Plan not found',
], 404);
}
return response()->json([
'success' => true,
'data' => [
'plan' => [
'id' => $plan->id,
'slug' => $plan->slug,
'name' => $plan->name,
'description' => $plan->description,
'price' => $plan->price,
'formatted_price' => $plan->formatted_price,
'monthly_price' => $plan->monthly_price,
'currency' => $plan->currency,
'billing_period' => $plan->billing_period,
'trial_days' => $plan->trial_days,
'features' => $plan->features,
'limits' => $plan->limits,
'is_free' => $plan->is_free,
'is_featured' => $plan->is_featured,
'has_trial' => $plan->has_trial,
'savings_percent' => $plan->savings_percent,
],
],
]);
}
}