Skip to content

Commit 8b60bbc

Browse files
committed
♻️ refactoring code
1 parent bee3be4 commit 8b60bbc

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

app/Http/Livewire/Articles/Browse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\Tag;
77
use App\Traits\WithInfiniteScroll;
88
use App\Traits\WithTags;
9+
use Illuminate\Contracts\View\View;
910
use Livewire\Component;
1011

1112
class Browse extends Component
@@ -26,7 +27,7 @@ public function validSort($sort): bool
2627
]);
2728
}
2829

29-
public function render()
30+
public function render(): View
3031
{
3132
$articles = Article::with('tags')->published()
3233
->notPinned()

app/Http/Livewire/Discussions/Browse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\Tag;
77
use App\Traits\WithInfiniteScroll;
88
use App\Traits\WithTags;
9+
use Illuminate\Contracts\View\View;
910
use Livewire\Component;
1011

1112
class Browse extends Component
@@ -17,7 +18,7 @@ class Browse extends Component
1718
'sortBy' => ['except' => 'recent'],
1819
];
1920

20-
public function validSort($sort): bool
21+
public function validSort(string $sort): bool
2122
{
2223
return in_array($sort, [
2324
'recent',
@@ -26,7 +27,7 @@ public function validSort($sort): bool
2627
]);
2728
}
2829

29-
public function render()
30+
public function render(): View
3031
{
3132
$discussions = Discussion::with('tags')
3233
->withCount('replies')

app/Traits/WithInfiniteScroll.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait WithInfiniteScroll
1010

1111
public int $perPage = 10;
1212

13-
public function loadMore()
13+
public function loadMore(): void
1414
{
1515
$this->perPage += 10;
1616
}

app/Traits/WithTags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ trait WithTags
1010

1111
public string $sortBy = 'recent';
1212

13-
public function toggleTag($tag): void
13+
public function toggleTag(string $tag): void
1414
{
1515
$this->tag = $this->tag !== $tag && $this->tagExists($tag) ? $tag : null;
1616
}
1717

18-
public function sortBy($sort): void
18+
public function sortBy(string $sort): void
1919
{
2020
$this->sortBy = $this->validSort($sort) ? $sort : 'recent';
2121
}

database/factories/DiscussionFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
class DiscussionFactory extends Factory
99
{
10-
public function definition()
10+
/**
11+
* Define the model's default state.
12+
*
13+
* @return array<string, mixed>
14+
*/
15+
public function definition(): array
1116
{
1217
return [
1318
'user_id' => $attributes['user_id'] ?? User::factory(),

0 commit comments

Comments
 (0)