Skip to content

Commit d9d2f4b

Browse files
committed
wip
1 parent c70bf09 commit d9d2f4b

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

app/Jobs/CreateArticle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ public function handle(): void
6969

7070
private function canBeAutoApproved(): bool
7171
{
72-
return $this->shouldBeSubmitted && $this->author->verifiedAuthorCanPublishMoreToday();
72+
return $this->shouldBeSubmitted && $this->author->canVerifiedAuthorPublishMoreArticleToday();
7373
}
7474
}

app/Models/Article.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function isShared(): bool
196196

197197
public function isAwaitingApproval(): bool
198198
{
199-
return $this->isSubmitted() && $this->isNotApproved() && $this->isNotDeclined() && ! $this->author()->verifiedAuthorCanPublishMoreToday();
199+
return $this->isSubmitted() && $this->isNotApproved() && $this->isNotDeclined() && ! $this->author()->canVerifiedAuthorPublishMoreArticleToday();
200200
}
201201

202202
public function isNotAwaitingApproval(): bool

app/Models/User.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ protected function casts(): array
7373
{
7474
return [
7575
'allowed_notifications' => 'array',
76+
'author_verified_at' => 'datetime',
7677
];
7778
}
7879

@@ -310,15 +311,7 @@ public function isVerifiedAuthor(): bool
310311
return ! is_null($this->author_verified_at) || $this->isAdmin();
311312
}
312313

313-
/**
314-
* Check if the verified author can publish more articles today.
315-
*
316-
* Verified authors are allowed to publish up to 2 articles per day,
317-
* but will start count from the moment they are verified.
318-
*
319-
* @return bool True if under the daily limit, false otherwise
320-
*/
321-
public function verifiedAuthorCanPublishMoreToday(): bool
314+
public function canVerifiedAuthorPublishMoreArticleToday(): bool
322315
{
323316
if ($this->isAdmin()) {
324317
return true;
@@ -330,7 +323,7 @@ public function verifiedAuthorCanPublishMoreToday(): bool
330323

331324
$publishedTodayCount = $this->articles()
332325
->whereDate('submitted_at', today())
333-
->where('submitted_at', '>', $this->author_verified_at)->count(); // to ensure we only count articles published after verify the author
326+
->count();
334327

335328
return $publishedTodayCount < 2;
336329
}

resources/views/articles/overview.blade.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,19 @@
153153
<x-avatar :user="$author" class="w-10 h-10" />
154154

155155
<span class="flex flex-col flex-1 min-w-0">
156-
<a href="{{ route('profile', $author->username()) }}" class="truncate hover:underline">
157-
<span class="text-gray-900 font-medium">
158-
{{ $author->username() }}
159-
</span>
160-
</a>
156+
<span class="flex items-center gap-x-1">
157+
<a href="{{ route('profile', $author->username()) }}" class="truncate hover:underline">
158+
<span class="text-gray-900 font-medium">
159+
{{ $author->username() }}
160+
</span>
161+
</a>
162+
163+
@if ($author->isVerifiedAuthor())
164+
<span title="This is a verified author">
165+
@svg('heroicon-s-check-badge', 'w-5 h-5 text-lio-500')
166+
</span>
167+
@endif
168+
</span>
161169

162170
<span class="text-gray-700">
163171
{{ $author->articles_count }} {{ Str::plural('Article', $author->articles_count) }}

resources/views/articles/show.blade.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ class="prose prose-lg text-gray-800 prose-lio"
149149
</div>
150150

151151
<div class="flex flex-col items-center text-gray-900 text-xl font-semibold lg:items-start">
152-
<a href="{{ route('profile', $article->author()->username()) }}" class="hover:underline">
153-
{{ $article->author()->username() }} ({{ $article->author()->name() }})
154-
</a>
152+
<span class="flex items-center gap-x-1">
153+
<a href="{{ route('profile', $article->author()->username()) }}" class="hover:underline">
154+
{{ $article->author()->username() }} ({{ $article->author()->name() }})
155+
</a>
156+
157+
@if ($article->author()->isVerifiedAuthor())
158+
<span title="This is a verified author">
159+
@svg('heroicon-s-check-badge', 'w-6 h-6 text-lio-500')
160+
</span>
161+
@endif
162+
</span>
155163

156164
<span class="text-lg text-gray-700 font-medium">
157165
{{ $article->author()->bio() }}

tests/Feature/ArticleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@
594594
'submitted_at' => now()->addMinutes(1), // after verification
595595
]);
596596

597-
expect($author->verifiedAuthorCanPublishMoreToday())->toBeFalse();
597+
expect($author->canVerifiedAuthorPublishMoreArticleToday())->toBeFalse();
598598
});
599599

600600
test('verified authors skip the approval message when submitting new article', function () {

0 commit comments

Comments
 (0)