Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Gummibeer/gummibeer.de

11 stars
3 code files
View Gummibeer/gummibeer.de on GitHub

app/Author.php

Open in GitHub
use 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 GitHub
use App\Author;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
 
class AuthorRepository
{
public function all(): Collection
{
return collect([
[
'nickname' => 'Gummibeer',
'email' => '[email protected]',
'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 GitHub
use App\Repositories\AuthorRepository;
use Illuminate\Support\ServiceProvider;
 
class AppServiceProvider extends ServiceProvider
{
public function registerRepositories(): void
{
//
$this->app->singleton(AuthorRepository::class);
}
}