first commit

This commit is contained in:
Uther
2024-08-20 21:08:23 +02:00
commit a46fcb28b0
80 changed files with 13840 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use App\Http\Services\PhantasialandApi;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ThemeParkUser extends Model
{
use HasFactory;
protected $fillable = [
'username',
'password',
];
public function authenticate(): void
{
if(!$this->isTokenExpired()) {
return;
}
$this->refreshToken();
}
private function refreshToken(): void
{
$api = app(PhantasialandApi::class);
$token = $api->getAccessToken($this);
$this->access_token = $token;
$this->access_token_expires_at = now()->addMonths(11);
$this->save();
}
private function isTokenExpired(): bool
{
return $this?->access_token_expires_at < now();
}
}

47
app/Models/User.php Executable file
View File

@@ -0,0 +1,47 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}