diff --git a/app/Http/Controllers/SessionController.php b/app/Http/Controllers/SessionController.php index 899c8e4..7c10c4c 100644 --- a/app/Http/Controllers/SessionController.php +++ b/app/Http/Controllers/SessionController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use Illuminate\Support\Facades\Auth; +use Illuminate\Validation\ValidationException; use Illuminate\Http\Request; class SessionController extends Controller @@ -20,7 +22,7 @@ class SessionController extends Controller if( !Auth::attempt($validatedAttributes) ) { - throw ValidationException::withMessages(['email' => 'wrong password']); + throw ValidationException::withMessages(['email' => 'credentials do not match']); } request()->session()->regenerate(); diff --git a/app/Models/Article.php b/app/Models/Article.php new file mode 100644 index 0000000..2f01c5d --- /dev/null +++ b/app/Models/Article.php @@ -0,0 +1,47 @@ + 1, + 'title' => 'First One', + 'slug' => '1st', + 'body' => 'First!!1
+ lol', + ], + [ 'id' => 2, + 'title' => 'Second One', + 'slug' => '2nd', + 'body' => 'Second i do concour
+ lmfao', + ], + [ 'id' => 3, + 'title' => 'Third One', + 'slug' => '3rd', + 'body' => 'Third indeed
+ xD', + ], + ]; + } + + public static function find(string $slug): array + { + $article = Arr::first(Article::all(), fn($article) => $article['slug'] === $slug); + + if(! $article ) { + abort(404); + } + + return $article; + } + +} diff --git a/public/css/style.css b/public/css/style.css index d4dfc52..13095b0 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -719,4 +719,40 @@ dfn[title] ; align-self : flex-start } .x-input .error -{ grid-area : error } \ No newline at end of file +{ grid-area : error } + +ol +{ gap: 0.5rem +; flex-direction: column +} +ol + { counter-reset : ol_lvl_1 } +ol ol + { counter-reset : ol_lvl_2 } +ol ol ol + { counter-reset : ol_lvl_3 } + +ol > li::before + { content : counter( ol_lvl_1 ) '.' + ; counter-increment : ol_lvl_1 + } + +ol > li:has(ol:first-child)::before + { display : none } +ol > li > ol:first-child > li::before + { background : var( --bg ) } + +ol ol > li::before + { content : counter( ol_lvl_1 ) '.' counter( ol_lvl_2 ) '.' + ; counter-increment : ol_lvl_2 + } + +ol ol > li:has(ol:first-child)::before + { display : none } +ol ol > li > ol:first-child > li::before + { background : var( --bg ) } + +ol ol ol > li::before + { content : counter( ol_lvl_1 ) '.' counter( ol_lvl_2 ) '.' counter( ol_lvl_3 ) '.' + ; counter-increment : ol_lvl_3 + } diff --git a/resources/views/article.blade.php b/resources/views/article.blade.php new file mode 100644 index 0000000..bdf28bd --- /dev/null +++ b/resources/views/article.blade.php @@ -0,0 +1,21 @@ + + +
+ +

{{ $title ?? $slug }}

+ +
+{{ $body }} +
+ +
+ +@auth +
+ @csrf + Edit + +
+@endauth + +
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index a49c033..76e9edf 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,6 +1,6 @@ -
+ @csrf Register - - + @csrf password + Register @endguest @@ -39,7 +38,7 @@ {{ $slot }} -
+ @csrf
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index f89248e..9aaf317 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -1,5 +1,13 @@ -
+
+ {{ $greeting }}. {{ $self }} + +
    +@foreach($articles as $article) +
  1. {{ $article['title'] ?? $article['slug'] }} +@endforeach +
+ list of avatars used over the years, currently planning on visual collection for this type of postings
diff --git a/resources/views/page.blade.php b/resources/views/page.blade.php deleted file mode 100644 index 4057bcc..0000000 --- a/resources/views/page.blade.php +++ /dev/null @@ -1,7 +0,0 @@ - - -
- -
- -
diff --git a/routes/web.php b/routes/web.php index 0946b3a..cc5bf44 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,10 +1,17 @@ 'Hello', + 'self' => 'My name is Dym Sohin, im a web-developer', + 'articles' => Article::all(), + ]); +}); Route::view('/about', 'about'); Route::view('/graphics', 'graphics'); @@ -23,10 +30,10 @@ Route::name('admin.new')->get('/new', function () { Route::name('admin.edit')->get('/edit', function () { return view('admin.edit'); }); -Route::name('admin.edit')->get('/edit/{slug}', function ($name = null) { +Route::name('admin.edit')->get('/edit/{slug}', function ($slug = null) { return view('admin.edit'); })->where('slug', '[A-Za-z0-9-]+'); -Route::name('admin.index')->get('/admin', function ($name = null) { +Route::name('admin.index')->get('/admin', function () { return view('admin.index'); }); @@ -40,6 +47,13 @@ Route::post('/logout', [SessionController::class, 'destroy']); -Route::name('page.show')->get('/{slug}', function () { - return view('page'); +Route::get('/{slug}', function (string $slug) { + $article = Article::find($slug); + + return view('article', + [ 'article' => $article + , 'title' => $article['title'] + , 'slug' => $article['slug'] + , 'body' => $article['body'] + ]); })->where('slug', '[A-Za-z0-9-]+');