admin form view

This commit is contained in:
Dym Sohin 2024-08-09 11:32:25 +02:00
parent f5fd828697
commit a3f0284fc3
6 changed files with 49 additions and 56 deletions

View File

@ -27,7 +27,7 @@ class SessionController extends Controller
request()->session()->regenerate();
return redirect('/admin');
return redirect('/dashboard');
}
public function destroy()

View File

@ -1,10 +0,0 @@
<x-layout-admin>
<form class="col c w-30" method="post" name="edit_form" id="edit_form">
<input type="text" name="title" class="w-30">
<input type="text" name="slug" class="w-30" pattern="[A-Za-z0-9-]+" required>
<textarea name="body" class="w-30"></textarea>
<button onclick="edit_form.submit()">save</button>
</form>
</x-layout-admin>

View File

@ -1,3 +0,0 @@
<x-layout-admin>
</x-layout-admin>

View File

@ -1,3 +1,5 @@
@if( 'hidden' !== $attributes['type'] )
<div class="x-input"
title="{{ $attributes['title'] ?? $slot }}"
>
@ -14,4 +16,6 @@
@error( "$slot" )
<p class="error">{{ $message }}</p>
@enderror
</div>
</div>
@endif

View File

@ -3,24 +3,32 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf8">
<title>{{ request()->path() }}</title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/admin.css">
</head>
<body>
<nav class="c">
<div class="buttons round">
<x-nav-link class="orange">new</x-nav-link>
<x-nav-link class="rose">list</x-nav-link>
<x-nav-link class="pink">tags</x-nav-link>
<x-nav-link class="teal">collections</x-nav-link>
<x-nav-link class="gray">/</x-nav-link>
</div>
<form method="get" action="/search">
<input type="search" name="q">
<button type="submit">search</button>
</form>
<a href="/dashboard">articles</a>
<a href="/new">new</a>
<a href="/categories">categories</a>
<a href="/collections">collections</a>
<a href="/tags">tags</a>
@auth
<form class="col c" method="post" name="logout_form" action="/logout">
@csrf
<button type="submit">Logout</button>
</form>
@endauth
</nav>
<main>
@guest
<form class="col c" method="post" name="login_form" action="/login">
@csrf
<x-input type="email" :value="old('email')"
@ -36,24 +44,7 @@
@auth
{{ $slot }}
<form class="col c" method="post" name="logout_form" action="/logout">
@csrf
<button type="submit">Logout</button>
</form>
@endauth
</main>
<footer class="c">
<form class="buttons round c" method="get" name="search_form">
<input type="search" name="search" placeholder="search">
<button onclick="search_form.submit()"
class="gray" title="search"
><span class="hidden">search</span>
</button>
<x-nav-link class="orange">rss</x-nav-link>
</a>
</form>
</footer>
</body></html>
</body></html>

View File

@ -21,20 +21,25 @@ Route::view('/code', 'code');
Route::view('/notes', 'notes');
Route::name('pages.list')->get('/list', function () {
return view('list');
Route::get('/new', function () {
return view('new');
});
Route::name('admin.new')->get('/new', function () {
return view('admin.edit');
});
Route::name('admin.edit')->get('/edit', function () {
return view('admin.edit');
});
Route::name('admin.edit')->get('/edit/{slug}', function ($slug = null) {
return view('admin.edit');
Route::get('/edit/{slug}', function (string $slug) {
$article = Article::find($slug);
return view('edit',
[ 'article' => $article
, 'title' => $article['title']
, 'slug' => $article['slug']
, 'body' => $article['body']
]);
})->where('slug', '[A-Za-z0-9-]+');
Route::name('admin.index')->get('/admin', function () {
return view('admin.index');
Route::get('/dashboard', function () {
return view('dashboard', [
'articles' => Article::all(),
]);
});
@ -45,6 +50,11 @@ Route::get('/login', [SessionController::class, 'create']);
Route::post('/login', [SessionController::class, 'store']);
Route::post('/logout', [SessionController::class, 'destroy']);
Route::get('/search/{search}', function (string $search) {
return view('list',
[ 'search' => $search ]
);
})->where('search', '.*');
Route::get('/{slug}', function (string $slug) {
@ -57,3 +67,4 @@ Route::get('/{slug}', function (string $slug) {
, 'body' => $article['body']
]);
})->where('slug', '[A-Za-z0-9-]+');