build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Features\Settings\UserSetting;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use N3XT0R\LaravelWebdavServer\Models\WebDavAccountModel;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
#[Hidden(['password', 'remember_token'])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function saveFiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Features\Settings\Models\SaveFile::class);
|
||||
}
|
||||
|
||||
public function settings(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserSetting::class);
|
||||
}
|
||||
|
||||
public function webDavAccounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebDavAccountModel::class);
|
||||
}
|
||||
|
||||
public function getSetting(string $key, mixed $default = null): mixed
|
||||
{
|
||||
$setting = $this->settings()->where('setting_key', $key)->first();
|
||||
|
||||
return $setting?->setting_value ?? $default;
|
||||
}
|
||||
|
||||
public function setSetting(string $key, mixed $value): void
|
||||
{
|
||||
$this->settings()->updateOrCreate(
|
||||
['setting_key' => $key],
|
||||
['setting_value' => $value]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user