From 919e5349283c3fa4ac2fdf05dc7c1e6ba27a1d90 Mon Sep 17 00:00:00 2001
From: Jordan <56432409+xrhythmic@users.noreply.github.com>
Date: Thu, 4 Nov 2021 19:21:11 +0000
Subject: [PATCH] Add Basic Front End for Posts CW3
---
.../views/components/post-layout.blade.php | 9 +++++++
resources/views/post.blade.php | 19 ++++++++++++++
resources/views/posts.blade.php | 23 ++++++++++++++++
routes/web.php | 26 ++++++++++++++++++-
4 files changed, 76 insertions(+), 1 deletion(-)
create mode 100644 resources/views/components/post-layout.blade.php
create mode 100644 resources/views/post.blade.php
create mode 100644 resources/views/posts.blade.php
diff --git a/resources/views/components/post-layout.blade.php b/resources/views/components/post-layout.blade.php
new file mode 100644
index 0000000..08afe72
--- /dev/null
+++ b/resources/views/components/post-layout.blade.php
@@ -0,0 +1,9 @@
+
+
+
Feta
+
+
+
+ {{ $slot }}
+
+
diff --git a/resources/views/post.blade.php b/resources/views/post.blade.php
new file mode 100644
index 0000000..da7529e
--- /dev/null
+++ b/resources/views/post.blade.php
@@ -0,0 +1,19 @@
+
+
+ {{ $post->title }}
+
+
+ By
+ {{ $post->author->name }}
+ in
+ {{ $post->category->name }}
+
+
+
+
+ {!! $post->body !!}
+
+
+
+ Go Back!
+
\ No newline at end of file
diff --git a/resources/views/posts.blade.php b/resources/views/posts.blade.php
new file mode 100644
index 0000000..92135cd
--- /dev/null
+++ b/resources/views/posts.blade.php
@@ -0,0 +1,23 @@
+
+ @foreach ($posts as $post)
+
+
+
+
+ By
+ {{ $post->author->name }}
+ in
+ {{ $post->category->name }}
+
+
+
+
+ {{ $post->excerpt }}
+
+
+ @endforeach
+
\ No newline at end of file
diff --git a/routes/web.php b/routes/web.php
index 852b11f..be2858b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,5 +1,9 @@
Post::latest()->with(['category', 'author'])->get()
+ ]);
+});
+
+Route::get('posts/{post}', function ($id) {
+ return view('post', [
+ 'post' => Post::findOrFail($id)
+ ]);
+});
+
+Route::get('categories/{category:slug}', function (Category $category) {
+ return view('posts', [
+ 'posts' => $category->posts
+ ]);
+});
+
+Route::get('authors/{author:username}', function (User $author) {
+ return view('posts', [
+ 'posts' => $author->posts
+ ]);
});
Route::get('/dashboard', function () {