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(); request()->session()->regenerate();
return redirect('/admin'); return redirect('/dashboard');
} }
public function destroy() 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" <div class="x-input"
title="{{ $attributes['title'] ?? $slot }}" title="{{ $attributes['title'] ?? $slot }}"
> >
@ -14,4 +16,6 @@
@error( "$slot" ) @error( "$slot" )
<p class="error">{{ $message }}</p> <p class="error">{{ $message }}</p>
@enderror @enderror
</div> </div>
@endif

View File

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

View File

@ -21,20 +21,25 @@ Route::view('/code', 'code');
Route::view('/notes', 'notes'); Route::view('/notes', 'notes');
Route::name('pages.list')->get('/list', function () { Route::get('/new', function () {
return view('list'); return view('new');
}); });
Route::name('admin.new')->get('/new', function () {
return view('admin.edit'); Route::get('/edit/{slug}', function (string $slug) {
}); $article = Article::find($slug);
Route::name('admin.edit')->get('/edit', function () {
return view('admin.edit'); return view('edit',
}); [ 'article' => $article
Route::name('admin.edit')->get('/edit/{slug}', function ($slug = null) { , 'title' => $article['title']
return view('admin.edit'); , 'slug' => $article['slug']
, 'body' => $article['body']
]);
})->where('slug', '[A-Za-z0-9-]+'); })->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('/login', [SessionController::class, 'store']);
Route::post('/logout', [SessionController::class, 'destroy']); 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) { Route::get('/{slug}', function (string $slug) {
@ -57,3 +67,4 @@ Route::get('/{slug}', function (string $slug) {
, 'body' => $article['body'] , 'body' => $article['body']
]); ]);
})->where('slug', '[A-Za-z0-9-]+'); })->where('slug', '[A-Za-z0-9-]+');