Add admin-editable About page
Mirrors the existing Bio singleton pattern: a new `about` table/model, admin CRUD at /admin/about, and a public page at /about linked from both the header nav and the admin homepage. Content is wrapped in .e-content so it lays out correctly within the site's CSS grid. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bzYwaDD8p3XNDMYKvXKrs
This commit is contained in:
parent
9532aae37e
commit
9e9fbdc127
12 changed files with 252 additions and 0 deletions
16
app/Http/Controllers/AboutPageController.php
Normal file
16
app/Http/Controllers/AboutPageController.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\About;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AboutPageController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
return view('about', [
|
||||
'about' => About::first()?->content,
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Admin/AboutController.php
Normal file
32
app/Http/Controllers/Admin/AboutController.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\About;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AboutController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
$about = About::first();
|
||||
|
||||
return view('admin.about.show', [
|
||||
'aboutEntry' => $about,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$about = About::firstOrNew();
|
||||
$about->content = $request->input('content');
|
||||
$about->save();
|
||||
|
||||
return redirect()->route('admin.about.show');
|
||||
}
|
||||
}
|
||||
13
app/Models/About.php
Normal file
13
app/Models/About.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class About extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'about';
|
||||
}
|
||||
Loading…
Reference in a new issue