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 <noreply@anthropic.com>
This commit is contained in:
@@ -9,11 +9,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
class FavoriteController extends Controller
|
class FavoriteController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->middleware('auth');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toggleExercise(Exercise $exercise): RedirectResponse
|
public function toggleExercise(Exercise $exercise): RedirectResponse
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('exercises', function (Blueprint $table) {
|
||||||
|
$table->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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user