refactor: reorganize FeedbackService methods; move delete method and restore pendingCount method for improved clarity
This commit is contained in:
parent
32c04b91dd
commit
f6da193473
@ -41,17 +41,6 @@ public function __construct()
|
|||||||
$this->sanitizer = new HtmlSanitizer($config);
|
$this->sanitizer = new HtmlSanitizer($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pendingCount(User $user): int
|
|
||||||
{
|
|
||||||
if (! $user->can('update-feedback-status')) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Feedback::query()
|
|
||||||
->where('status', FeedbackStatus::Submitted)
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function paginated(User $user, int $perPage = 25, string $search = '', ?string $type = null, ?string $status = null): LengthAwarePaginator
|
public function paginated(User $user, int $perPage = 25, string $search = '', ?string $type = null, ?string $status = null): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
return Feedback::query()
|
return Feedback::query()
|
||||||
@ -85,6 +74,11 @@ public function update(Feedback $feedback, array $data): Feedback
|
|||||||
return $feedback;
|
return $feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Feedback $feedback): bool
|
||||||
|
{
|
||||||
|
return $feedback->delete();
|
||||||
|
}
|
||||||
|
|
||||||
public function updateStatus(Feedback $feedback, string $status): Feedback
|
public function updateStatus(Feedback $feedback, string $status): Feedback
|
||||||
{
|
{
|
||||||
$feedback->update([
|
$feedback->update([
|
||||||
@ -107,8 +101,14 @@ public function reply(Feedback $feedback, string $reply): Feedback
|
|||||||
return $feedback;
|
return $feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(Feedback $feedback): bool
|
public function pendingCount(User $user): int
|
||||||
{
|
{
|
||||||
return $feedback->delete();
|
if (! $user->can('update-feedback-status')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Feedback::query()
|
||||||
|
->where('status', FeedbackStatus::Submitted)
|
||||||
|
->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user