Skip to content

Commit dfac4bb

Browse files
committed
wip
1 parent 2ec0997 commit dfac4bb

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

app/Models/Article.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ protected function casts(): array
7878
'submitted_at' => 'datetime',
7979
'approved_at' => 'datetime',
8080
'shared_at' => 'datetime',
81+
'is_pinned' => 'boolean',
82+
'is_sponsored' => 'boolean',
8183
];
8284
}
8385

@@ -174,7 +176,12 @@ public function isNotPublished(): bool
174176

175177
public function isPinned(): bool
176178
{
177-
return (bool) $this->is_pinned;
179+
return $this->is_pinned;
180+
}
181+
182+
public function isSponsored(): bool
183+
{
184+
return $this->is_sponsored;
178185
}
179186

180187
public function isNotShared(): bool

database/factories/ArticleFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function definition(): array
1818
'body' => $this->faker->paragraphs(3, true),
1919
'slug' => $this->faker->unique()->slug(),
2020
'view_count' => $this->faker->numberBetween(0, 1000),
21+
'is_sponsored' => $this->faker->boolean(),
2122
];
2223
}
2324

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table('articles', function (Blueprint $table) {
12+
$table->boolean('is_sponsored')->after('is_pinned')->default(false);
13+
});
14+
}
15+
};

resources/views/components/articles/overview-summary.blade.php

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
{{ $article->createdAt()->format('j M, Y') }}
4242
</span>
4343
@endif
44+
45+
@if ($article->isSponsored())
46+
<x-tag class="ml-5 text-xs">Sponsored</x-tag>
47+
@endif
4448
</div>
4549

4650
@if (isset($mode) && $mode == 'edit')

resources/views/components/articles/summary.blade.php

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
<span class="font-mono text-gray-700 leading-6 mb-2 block">
2121
{{ $article->submittedAt()->format('F jS Y') }}
22+
23+
@if ($article->isSponsored())
24+
<x-tag>Sponsored</x-tag>
25+
@endif
2226
</span>
2327

2428
@if ($isFeatured)

0 commit comments

Comments
 (0)