Files
Deathgarden_Rebirth-Rewrite/dist/app/Models/User/User.php
Vari 1bf28e2c50 Added package spatie/laravel-permission for adding roles and permissions.
Setup default admin and view-log role and permission (the whole reason i added all this stuff).

also added artisan command to give user a role via command line with artisan permissions:AddRoleToUser {rolename} {userId}
2024-02-14 21:50:42 +01:00

33 lines
720 B
PHP

<?php
namespace App\Models\User;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Spatie\Permission\Traits\HasRoles;
/**
* @mixin \Eloquent
* @mixin IdeHelperUser
*/
class User extends Model implements \Illuminate\Contracts\Auth\Authenticatable
{
use HasUuids, Authenticatable, HasRoles;
protected $fillable = [
'steam_id',
];
public function ban(): HasOne
{
return $this->hasOne(Ban::class);
}
public static function findBySteamID(int $steamId): User|null
{
return static::where('steam_id', $steamId)->first();
}
}