feat: add category management

associate with entries and text widgets
This commit is contained in:
jon brookes 2026-01-09 13:18:37 +00:00
parent c83028b4d4
commit 9b9e1a8e29
22 changed files with 392 additions and 46 deletions

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Resources\TextWidgetResource;
use App\Models\TextWidget;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@ -13,7 +14,7 @@ class TextWidgetController extends Controller
*/
public function index()
{
return TextWidget::all();
return TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw));
}
/**
@ -33,7 +34,7 @@ class TextWidgetController extends Controller
'content' => 'required|string',
]);
return TextWidget::create($validated);
return new TextWidgetResource(TextWidget::create($validated));
}
/**
@ -41,7 +42,7 @@ class TextWidgetController extends Controller
*/
public function show(TextWidget $textWidget)
{
return $textWidget;
return new TextWidgetResource($textWidget->load('category'));
}
/**
@ -57,7 +58,7 @@ class TextWidgetController extends Controller
$textWidget->update($validated);
return $textWidget;
return new TextWidgetResource($textWidget->load('category'));
}
/**