-
app/Author.php
Open in GitHubuse App\Services\Model; final class Author extends Model { public function __call($name, $arguments) { return call_user_func_array([app(AuthorRepository::class), $name], $arguments); } }
-
app/Repositories/AuthorRepository.php
Open in GitHubuse App\Author; use Illuminate\Support\Collection; use Illuminate\Support\Str; class AuthorRepository { public function all(): Collection { return collect([ [ 'nickname' => 'Gummibeer', 'email' => 'dev@gummibeer.de', 'firstname' => 'Tom', 'lastname' => 'Witkowski', 'payment_pointer' => '$ilp.uphold.com/EagWEdJU64mN', 'twitter' => '@devgummibeer', ], ]) ->mapInto(Author::class); } public function find(string $nickname): Author { return $this->all() ->first(fn (Author $author): bool => Str::slug($author->nickname) === Str::slug($nickname)); } }
-
app/Providers/AppServiceProvider.php
Open in GitHubuse App\Repositories\AuthorRepository; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function registerRepositories(): void { // $this->app->singleton(AuthorRepository::class); } }