Switch bio to be stored in database
This commit is contained in:
parent
f51a740858
commit
bdb69df52d
14 changed files with 219 additions and 38 deletions
32
app/Http/Controllers/Admin/BioController.php
Normal file
32
app/Http/Controllers/Admin/BioController.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\Bio;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BioController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
$bio = Bio::first();
|
||||
|
||||
return view('admin.bio.show', [
|
||||
'bioEntry' => $bio,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$bio = Bio::firstOrNew();
|
||||
$bio->content = $request->input('content');
|
||||
$bio->save();
|
||||
|
||||
return redirect()->route('admin.bio.show');
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Bio;
|
||||
use App\Models\Bookmark;
|
||||
use App\Models\Like;
|
||||
use App\Models\Note;
|
||||
|
@ -34,8 +35,11 @@ class FrontPageController extends Controller
|
|||
->sortByDesc('updated_at')
|
||||
->paginate(10);
|
||||
|
||||
$bio = Bio::first()?->content;
|
||||
|
||||
return view('front-page', [
|
||||
'items' => $items,
|
||||
'bio' => $bio,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue