first commit
This commit is contained in:
36
app/Providers/AppServiceProvider.php
Executable file
36
app/Providers/AppServiceProvider.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Http\Services\PhantasialandApi;
|
||||
use App\Models\ThemeParkUser;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->app->bind(ThemeParkUser::class, function () {
|
||||
$api = app(PhantasialandApi::class);
|
||||
if(ThemeParkUser::query()->count() === 0) {
|
||||
$userData = $api->createUser();
|
||||
return ThemeParkUser::query()->create([
|
||||
'username' => $userData['email'],
|
||||
'password' => $userData['password'],
|
||||
]);
|
||||
}
|
||||
return ThemeParkUser::query()->first();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user