for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Xetaravel\Models\Presenters;
use Illuminate\Database\Eloquent\Casts\Attribute;
trait DiscussConversationPresenter
{
/**
* We must decrement the post count due to the first post being counted.
*
* @return Attribute
*/
protected function postCountFormated(): Attribute
return Attribute::make(
get: fn () => $this->post_count - 1
);
}
* Get the conversation url.
protected function conversationUrl(): Attribute
get: fn () => route('discuss.conversation.show', ['slug' => $this->slug, 'id' => $this->getKey()])
getKey()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
get: fn () => route('discuss.conversation.show', ['slug' => $this->slug, 'id' => $this->/** @scrutinizer ignore-call */ getKey()])
* Get the last page number for the conversation.
protected function lastPage(): Attribute
get: function () {
$posts = $this->post_count_formated;
if ($this->is_solved) {
$posts = $posts - 1;
$page = (int) ceil($posts / config('xetaravel.pagination.discuss.post_per_page'));
return $page ?: 1;