From 221493e56f75d54ae03bdab1f069ab87d7f53753 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 10 Aug 2026 11:47:44 +0300 Subject: [PATCH] Fix two live 500s: favorite toggle and admin exercise creation FavoriteController's constructor called $this->middleware('auth'), which no longer exists on Laravel 12's base Controller (removed in the framework's slimmer controller base). Every favorite-toggle request was 500ing. The routes already sit inside a Route::middleware('auth') group in web.php, so the constructor was both redundant and broken - removed it. Separately, exercises.exercise_db_id was NOT NULL with a unique constraint, but the admin "create exercise" form never set it (that column only gets populated by the fetch:exercise importer). Creating an exercise by hand through the admin UI has been broken since it was built. Made the column nullable. Both found by adding feature test coverage, not by manual testing. Co-Authored-By: Claude Sonnet 5 --- app/Http/Controllers/FavoriteController.php | 5 ---- ...cise_db_id_nullable_on_exercises_table.php | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2026_08_10_084617_make_exercise_db_id_nullable_on_exercises_table.php diff --git a/app/Http/Controllers/FavoriteController.php b/app/Http/Controllers/FavoriteController.php index 7ca7a3d..0f3076d 100644 --- a/app/Http/Controllers/FavoriteController.php +++ b/app/Http/Controllers/FavoriteController.php @@ -9,11 +9,6 @@ use Illuminate\Support\Facades\Auth; class FavoriteController extends Controller { - public function __construct() - { - $this->middleware('auth'); - } - public function toggleExercise(Exercise $exercise): RedirectResponse { $user = Auth::user(); diff --git a/database/migrations/2026_08_10_084617_make_exercise_db_id_nullable_on_exercises_table.php b/database/migrations/2026_08_10_084617_make_exercise_db_id_nullable_on_exercises_table.php new file mode 100644 index 0000000..a0bc294 --- /dev/null +++ b/database/migrations/2026_08_10_084617_make_exercise_db_id_nullable_on_exercises_table.php @@ -0,0 +1,28 @@ +string('exercise_db_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('exercises', function (Blueprint $table) { + $table->string('exercise_db_id')->nullable(false)->change(); + }); + } +};