-
app/Post.php
Open in GitHubuse App\Services\Model; final class Post extends Model { public function categories(): Collection { return collect($this->categories) ->map(fn (string $slug): array => ['slug' => $slug]) ->mapInto(Category::class); } }
use App\Services\Model;
final class Post extends Model
{
public function categories(): Collection
{
return collect($this->categories)
->map(fn (string $slug): array => ['slug' => $slug])
->mapInto(Category::class);
}
}