mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
101 lines
2.1 KiB
PHP
101 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name', 'email', 'password',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password', 'remember_token',
|
|
];
|
|
|
|
public function logs()
|
|
{
|
|
return $this->hasMany(Log::class);
|
|
}
|
|
|
|
public function updateAPI()
|
|
{
|
|
$this->api_token = str_random(60);
|
|
|
|
$this->save();
|
|
}
|
|
|
|
public function fullname()
|
|
{
|
|
$fullname = $this->lastname.' '.$this->firstname;
|
|
return $fullname;
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return $this->hasMany(Message::class);
|
|
}
|
|
|
|
public function routeNotificationForNexmo($notification)
|
|
{
|
|
return $this->telephone;
|
|
}
|
|
|
|
public function getPerm($perm)
|
|
{
|
|
$rank = \App\Rank::find($this->rank);
|
|
$job = \App\Job::find($this->job);
|
|
|
|
$rank_perm_value = $rank->$perm;
|
|
$job_perm_value = $job->$perm;
|
|
$user_perm_value = $this->$perm;
|
|
|
|
if ($user_perm_value == 1 ) {
|
|
$perm_value = 1;
|
|
} else if ($job_perm_value== 1) {
|
|
$perm_value = 1;
|
|
} else if ($rank_perm_value == 1) {
|
|
$perm_value = 1;
|
|
} else {
|
|
$perm_value = 0;
|
|
}
|
|
|
|
return $perm_value;
|
|
}
|
|
|
|
public function getAcces($level)
|
|
{
|
|
$rank = \App\Rank::find($this->rank);
|
|
$job = \App\Job::find($this->job);
|
|
|
|
$rank_perm_value = $rank->acces_level;
|
|
$job_perm_value = $job->acces_level;
|
|
$user_perm_value = $this->acces_level;
|
|
|
|
if ($user_perm_value >= $level ) {
|
|
$perm_value = true;
|
|
} else if ($job_perm_value >= $level) {
|
|
$perm_value = true;
|
|
} else if ($rank_perm_value >= $level) {
|
|
$perm_value = true;
|
|
} else {
|
|
$perm_value = false;
|
|
}
|
|
return $perm_value;
|
|
}
|
|
}
|