Skip to content

Commit 46b0109

Browse files
committed
Merge branch 'main' into 4.x
2 parents 9c8f7b9 + 58cad90 commit 46b0109

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+215
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\Author;
7+
8+
class AuthorController extends Controller
9+
{
10+
public function index()
11+
{
12+
return Author::paginate();
13+
}
14+
15+
public function show(Author $author)
16+
{
17+
return $author->append('stars_count');
18+
}
19+
}

app/Models/Author.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Builder;
6+
use Illuminate\Database\Eloquent\Casts\Attribute;
67
use Illuminate\Database\Eloquent\Factories\HasFactory;
78
use Illuminate\Database\Eloquent\Model;
89
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -63,6 +64,13 @@ public function getStarsCount(): int
6364
);
6465
}
6566

67+
protected function starsCount(): Attribute
68+
{
69+
return Attribute::make(
70+
get: fn () => $this->getStarsCount(),
71+
);
72+
}
73+
6674
public function cacheStarsCount(): void
6775
{
6876
cache()->forget($this->getStarsCountCacheKey());
542 KB
196 KB
400 KB

content/authors/stephenjude.md

Lines changed: 6 additions & 0 deletions

content/authors/teguhrijanandi.md

Lines changed: 9 additions & 0 deletions

content/authors/visual-builder.md

Lines changed: 11 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
Lines changed: 14 additions & 0 deletions

0 commit comments

Comments
 (0)