mad-lawsuit/app/Http/Controllers/Admin/SubscriberController.php
TheMaddax b7125cf2b7 Phase 4: Production deployment configuration
- Add Docker configuration (Dockerfile, docker-compose.yml)
- Add Nginx and Supervisor configuration
- Add deployment documentation (DEPLOYMENT.md)
- Complete Phase 3 data migration (63 entries, 63 docs, 28 subs)
- Add responsive PDF viewer component
- Fix date format to American (MM/DD/YYYY)
- Update typography to match v1.0
- Add admin dashboard with full CRUD operations
- Configure PostgreSQL with secure password
- Connect to caddy_network for reverse proxy
- Ready for production deployment
2025-12-17 19:12:32 -07:00

53 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Subscription;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;
class SubscriberController extends Controller
{
/**
* Display a listing of subscribers.
*/
public function index(): Response
{
$subscribers = Subscription::orderBy('created_at', 'desc')
->paginate(50);
return Inertia::render('Admin/Subscribers/Index', [
'subscribers' => $subscribers->through(fn ($sub) => [
'id' => $sub->id,
'email' => $sub->email,
'is_active' => $sub->is_active,
'created_at' => $sub->created_at->format('Y-m-d H:i'),
]),
'pagination' => [
'current_page' => $subscribers->currentPage(),
'last_page' => $subscribers->lastPage(),
'per_page' => $subscribers->perPage(),
'total' => $subscribers->total(),
],
'stats' => [
'total' => Subscription::count(),
'active' => Subscription::where('is_active', true)->count(),
'inactive' => Subscription::where('is_active', false)->count(),
],
]);
}
/**
* Remove the specified subscriber.
*/
public function destroy(Subscription $subscription): RedirectResponse
{
// Soft delete by setting is_active to false
$subscription->update(['is_active' => false]);
return redirect()->route('admin.subscribers.index')
->with('success', 'Subscriber deactivated successfully.');
}
}