users and institutions route, tests fixed
This commit is contained in:
28
backend/app/Models/Lists/UserPosition.php
Normal file
28
backend/app/Models/Lists/UserPosition.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lists;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use OwenIt\Auditing\Auditable as AuditableTrait;
|
||||
use OwenIt\Auditing\Contracts\Auditable;
|
||||
|
||||
class UserPosition extends Model implements Auditable
|
||||
{
|
||||
use AuditableTrait;
|
||||
use HasFactory;
|
||||
|
||||
public const PROFESSOR = 'Professor';
|
||||
|
||||
public const RESEARCHER = 'Researcher';
|
||||
|
||||
public const PHD = 'PhD';
|
||||
|
||||
public const STUDENT = 'Student';
|
||||
|
||||
public const ADMINISTRATIVE = 'Administrative personnel';
|
||||
|
||||
protected $table = 'user_positions';
|
||||
|
||||
protected $fillable = ['value'];
|
||||
}
|
||||
@@ -38,20 +38,4 @@ class UserRole extends Model implements Auditable
|
||||
{
|
||||
return $this->hasMany(User::class, 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruolo predefinito di sistema: non eliminabile.
|
||||
*/
|
||||
public function isSystemRole(): bool
|
||||
{
|
||||
return in_array($this->name, [self::ADMIN, self::SUPERVISOR, self::USER, self::GUEST], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Il ruolo è assegnato ad almeno un utente.
|
||||
*/
|
||||
public function isInUse(): bool
|
||||
{
|
||||
return $this->users()->exists();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user