Skip to content

Commit 8644112

Browse files
Add Display Views in Admin
1 parent 6ff55b0 commit 8644112

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

database/migrations/2022_12_27_115916_create_posts_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function up()
2020
$table->text('content');
2121
$table->string('image');
2222
$table->boolean('status');
23-
$table->integer('views');
23+
$table->integer('views')->nullable();
2424
$table->foreignId('cat_id')->constrained('categories')->onDelete('cascade');
2525
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
2626
$table->timestamps();

resources/views/admin/post/index.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class="py-4 px-6 bg-grey-lightest font-bold uppercase text-sm text-grey-dark bor
2828
<th
2929
class="py-4 px-6 bg-grey-lightest font-bold uppercase text-sm text-grey-dark border-b border-grey-light">
3030
Tags</th>
31+
<th
32+
class="py-4 px-6 bg-grey-lightest font-bold uppercase text-sm text-grey-dark border-b border-grey-light">
33+
Views</th>
3134
<th
3235
class="py-4 px-6 bg-grey-lightest font-bold uppercase text-sm text-grey-dark border-b border-grey-light">
3336
Added by</th>
@@ -56,6 +59,13 @@ class="text-xs font-normal leading-none max-w-full flex-initial">
5659
@endforelse
5760
</div>
5861
</td>
62+
<td class="py-4 px-6 border-b border-grey-light">
63+
@if (isset($post->views))
64+
{{$post->views}}
65+
@else
66+
0
67+
@endif
68+
</td>
5969
<td class="py-4 px-6 border-b border-grey-light">{{ $post->user->name }}</td>
6070
<td class="py-4 px-6 border-b border-grey-light">
6171
@can('update', $post)

0 commit comments

Comments
 (0)