BlogController was an empty stub with no view, so /blog 500'd on every visit. Adds a real Post model, public listing/detail pages, and an admin CRUD screen mirroring the existing Exercise admin pattern (image upload or URL, auto-slug, publish toggle). Seeds 5 real posts so it's not empty on launch. Also fixes two things that were silently broken: phpunit.xml pointed DB_DATABASE at a non-existent "testing" file with no DB_CONNECTION set, and the stock ExampleTest had RefreshDatabase commented out - both meant the test suite never actually ran successfully. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
881 B
PHP
32 lines
881 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Exercise;
|
|
use App\Models\Post;
|
|
use App\Models\User;
|
|
use App\Models\Workout;
|
|
use App\Models\WorkoutSession;
|
|
use App\Models\YogaPose;
|
|
use Illuminate\View\View;
|
|
|
|
class AdminDashboardController extends Controller
|
|
{
|
|
public function index(): View
|
|
{
|
|
$metrics = [
|
|
'users' => User::count(),
|
|
'workouts' => Workout::count(),
|
|
'sessions' => WorkoutSession::count(),
|
|
'exercises' => Exercise::count(),
|
|
'yogaPoses' => YogaPose::count(),
|
|
'posts' => Post::count(),
|
|
];
|
|
|
|
$recentUsers = User::latest()->limit(5)->get(['id','name','email','created_at']);
|
|
$recentWorkouts = Workout::latest()->limit(5)->get(['id','title','created_at']);
|
|
|
|
return view('admin.dashboard', compact('metrics','recentUsers','recentWorkouts'));
|
|
}
|
|
}
|