Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions resources/views/components/post-layout.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>

<title> Feta </title>
<link rel="stylesheet" href="/app.css">

<body>
{{ $slot }}
<hr/>
</body>
19 changes: 19 additions & 0 deletions resources/views/post.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<x-post-layout>
<article>
<h1>{{ $post->title }}</h1>

<p>
By <a href="/authors/{{ $post->author->username }}">
{{ $post->author->name }}
</a> in <a href="/categories/{{ $post->category->slug }}">
{{ $post->category->name }}
</a>
</p>

<div>
{!! $post->body !!}
</div>
</article>

<a href="/">Go Back!</a>
</x-post_layout>
23 changes: 23 additions & 0 deletions resources/views/posts.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<x-post-layout>
@foreach ($posts as $post)
<article>
<h1>
<a href="/posts/{{ $post->id }}">
{{ $post->title }}
</a>
</h1>

<p>
By <a href="/authors/{{ $post->author->username }}">
{{ $post->author->name }}
</a> in <a href="/categories/{{ $post->category->slug }}">
{{ $post->category->name }}
</a>
</p>

<div>
{{ $post->excerpt }}
</div>
</article>
@endforeach
</x-post_layout>
26 changes: 25 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use App\Models\Post;
use App\Models\Category;
use App\Models\User;

use Illuminate\Support\Facades\Route;

/*
Expand All @@ -14,7 +18,27 @@
*/

Route::get('/', function () {
return view('welcome');
return view('posts', [
'posts' => 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 () {
Expand Down