Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Amelia Priti Usparida
CobaMagang_AmeliaPriti
Commits
c3bd519b
Commit
c3bd519b
authored
3 years ago
by
Amelia Priti Usparida
Browse files
Options
Download
Email Patches
Plain Diff
coba
parent
66527ac4
main
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app/Models/Category.php
+5
-0
app/Models/Category.php
resources/views/categories.blade.php
+17
-0
resources/views/categories.blade.php
resources/views/category.blade.php
+15
-0
resources/views/category.blade.php
resources/views/post.blade.php
+7
-6
resources/views/post.blade.php
routes/web.php
+15
-1
routes/web.php
with
59 additions
and
7 deletions
+59
-7
app/Models/Category.php
View file @
c3bd519b
...
...
@@ -10,4 +10,9 @@ class Category extends Model
use
HasFactory
;
protected
$guarded
=
[
'id'
];
public
function
post
()
{
return
$this
->
hasMany
(
Post
::
class
);
}
}
This diff is collapsed.
Click to expand it.
resources/views/categories.blade.php
0 → 100644
View file @
c3bd519b
@
extends
(
'layouts/main'
)
@
section
(
'container'
)
<
h1
class
=
"mb-5"
>
Post
Categories
:
{{
$category
}}
</
h1
>
@
foreach
(
$categories
as
$categories
)
,
ul
>
<
li
>
<
h2
><
a
href
=
"/categories/{{
$category->slug
}}"
>
{{
$category
->
name
}}
</
a
></
h2
>
</
li
>
</
ul
>
@
endforeach
@
endsection
This diff is collapsed.
Click to expand it.
resources/views/category.blade.php
0 → 100644
View file @
c3bd519b
@
extends
(
'layouts/main'
)
@
section
(
'container'
)
<
h1
class
=
"mb-5"
>
Post
Category
:
{{
$category
}}
</
h1
>
@
foreach
(
$category
as
$category
)
<
article
>
<
h2
><
a
href
=
"/posts/{{
$post->slug
}}"
>
{{
$post
->
title
}}
</
a
></
h2
>
<
p
>
{{
$post
->
excerpt
}}
</
p
>
</
article
>
@
endforeach
@
endsection
This diff is collapsed.
Click to expand it.
resources/views/post.blade.php
View file @
c3bd519b
@
extends
(
'layouts.main'
)
@
section
(
'container'
)
<
article
>
<
h2
>
{{
$post
->
title
}}
</
h2
>
<
h5
>
{{
$post
->
author
}}
</
h5
>
{
!!
$post
->
body
!!
}
</
article
>
<
h1
class
=
"mb-5"
{{
$post
->
title
}}
</
h1
>
<
p
>
By
.
Amelia
Priti
Usparida
in
<
a
href
=
"/categories/((
$post->category
->slug}}"
>
{{
$post
->
category
->
name
}}
</
a
></
p
>
{
!!
$post
->
body
!!
}
<
a
href
=
"/posts"
>
Back
to
Posts
</
a
>
<
a
href
=
"/blog"
>
Back
to
Posts
</
a
>
@
endsection
\ No newline at end of file
This diff is collapsed.
Click to expand it.
routes/web.php
View file @
c3bd519b
...
...
@@ -3,7 +3,7 @@
use
App\Models\Post
;
use
Illuminate\Support\Facades\Route
;
use
App\Http\Controllers\PostController
;
use
App\Models\Category
;
/*
|--------------------------------------------------------------------------
...
...
@@ -37,3 +37,17 @@
//halaman single post
Route
::
get
(
'posts/{post:slug}'
,
[
PostController
::
class
,
'show'
]);
Route
::
get
(
'/categories'
,
function
(){
return
view
(
'category'
,
[
'title'
=>
'Post Categories'
,
'categories'
=>
Category
::
all
()
]);
})
Route
::
get
(
'/categories/{category:slug}'
,
function
(
Category
$category
){
return
view
(
'category'
,
[
'title'
=>
$category
->
name
,
'posts'
=>
$category
->
posts
,
'category'
=>
$category
->
name
,
]);
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help