Add blog feature and fix broken test/build infra

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>
This commit is contained in:
2026-08-10 11:36:31 +03:00
co-authored by Claude Sonnet 5
parent beeda8139b
commit 4686dea609
21 changed files with 697 additions and 12 deletions
+115
View File
@@ -0,0 +1,115 @@
<?php
namespace Database\Seeders;
use App\Models\Post;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class PostSeeder extends Seeder
{
public function run(): void
{
$authorId = User::query()->where('is_admin', true)->value('id')
?? User::query()->value('id');
$posts = [
[
'title' => 'Progressive Overload 101: How to Actually Get Stronger',
'excerpt' => 'Lifting the same weight for the same reps every week is the most common reason strength progress stalls. Here is how progressive overload fixes that.',
'body' => <<<'MD'
If you have been training for a while but your lifts have not moved in months, the problem is usually not effort. It is that your body has nothing new to adapt to.
Progressive overload just means gradually increasing the demand you place on your muscles over time, whether that is more weight, more reps, more sets, or better technique that lets you work harder safely.
Start small. Adding 2.5kg to a lift once it feels comfortable for all your sets is enough. You do not need to chase a new personal record every session.
Track your workouts. It is easy to think you are progressing when you are not. Logging sets, reps, and weight (which is exactly what the Workouts feature here is for) removes the guesswork.
Rotate the variable you push. Some weeks add weight, other weeks add a rep, other weeks slow the tempo down. Your joints will thank you for not always maxing out load.
Recovery is part of the plan, not a break from it. Muscles grow during rest, not during the set. If you are not progressing, check your sleep and food before you check your program.
MD,
'published_at' => now()->subDays(21),
],
[
'title' => 'A Beginner’s Guide to Building Your First Weekly Workout Split',
'excerpt' => 'Not sure how to structure your week? Here is a simple, sustainable approach for people just getting started.',
'body' => <<<'MD'
The biggest mistake beginners make is copying an advanced athlete's six-day split in week one. You will burn out before you build the habit.
For most beginners, three full-body sessions per week, with a rest day between each, is plenty. It hits every major muscle group often enough to drive progress without wrecking your recovery.
A simple full-body session might include one push movement, one pull movement, one squat or hinge pattern, and one core exercise. That is it. You can build a workout like this in a couple of minutes using the workout builder.
As you get more consistent, usually after eight to twelve weeks, you can start splitting sessions further, for example upper/lower, if your schedule and recovery support the extra volume.
Consistency beats complexity every time. A simple plan you actually follow for three months will outperform a perfect plan you quit after two weeks.
MD,
'published_at' => now()->subDays(14),
],
[
'title' => 'Why Yoga Belongs in Every Training Program',
'excerpt' => 'Yoga is not just for flexibility. Here is what it actually does for people who lift, run, or play sport.',
'body' => <<<'MD'
Yoga tends to get filed under "recovery day filler," but the benefits go well beyond stretching.
Mobility work through yoga poses improves the range of motion you can access under load, which means better depth on squats and safer overhead positions.
Balance and single-leg poses build the small stabilizer muscles that heavy compound lifts do not always train directly, which helps prevent injuries.
Controlled breathing during yoga carries over directly into bracing for heavy lifts and staying calm under fatigue in endurance sports.
You do not need an hour-long session. Ten to fifteen minutes a couple of times a week, browsed right from the yoga library here, is enough to notice a difference within a month.
MD,
'published_at' => now()->subDays(7),
],
[
'title' => 'How Much Protein Do You Actually Need?',
'excerpt' => 'Protein advice online ranges from "barely matters" to "eat a chicken breast every two hours." Here is what the evidence actually supports.',
'body' => <<<'MD'
For most people training regularly, somewhere between 1.6 and 2.2 grams of protein per kilogram of bodyweight per day covers the range where muscle growth and recovery are well supported.
Above that range, more protein does not appear to meaningfully speed up progress for most people. It is not harmful in normal amounts, it is just not doing extra work once you are already in the effective range.
Spreading protein across three to four meals a day tends to be easier to hit consistently than trying to eat it all in one sitting, though total daily intake matters more than exact timing.
Whole food sources are worth prioritizing, but if you are short on a busy day, a protein shake closing the gap is completely fine.
The best protein target is the one you can hit consistently. A slightly lower number you actually eat every day beats a perfect number you hit twice a week.
MD,
'published_at' => now()->subDays(2),
],
[
'title' => 'Rest Days Are Not Optional: The Case for Recovery',
'excerpt' => 'Training harder is not always the answer. Sometimes the fastest way to progress is a well-placed day off.',
'body' => <<<'MD'
It is tempting to think more training always equals more progress, but the adaptation that makes you stronger, fitter, or faster happens during recovery, not during the workout itself.
Sleep is the single highest-leverage recovery tool available, and it is free. Poor sleep reduces strength output, increases injury risk, and blunts the muscle-building response to training.
Rest days do not have to mean total inactivity. A walk, light mobility work, or an easy yoga session keeps blood flowing without adding fatigue.
Watch for warning signs of under-recovery: workouts that feel harder than they should, irritability, poor sleep, or a resting heart rate that is creeping up. These are signals to back off, not push through.
Plan rest days into your week in advance instead of only taking one when you are too exhausted to train. A planned deload is far more productive than a forced one.
MD,
'published_at' => now()->subDay(),
],
];
foreach ($posts as $post) {
Post::query()->updateOrCreate(
['slug' => Str::slug($post['title'])],
[
'title' => $post['title'],
'excerpt' => $post['excerpt'],
'body' => $post['body'],
'author_id' => $authorId,
'published_at' => $post['published_at'],
]
);
}
}
}