users
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 25/12/2017
|
||||
* Time: 17:07
|
||||
*/
|
||||
|
||||
class Role extends BaseModel {
|
||||
|
||||
protected $table = "roles";
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne( 'User', 'role', 'rolelevel' );
|
||||
}
|
||||
|
||||
public static function getAllRoles( $archive )
|
||||
{
|
||||
$roleHierarchy = Role::getUserroleHierachy();
|
||||
|
||||
$roles = Role::orderBy( 'rolehierarchy' )
|
||||
->where( 'rolehierarchy', '>=', $roleHierarchy );
|
||||
|
||||
if ( $archive == 'F' ) $roles = $roles->whereArchive( 'F' );
|
||||
|
||||
$roles = $roles->get();
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
||||
public static function getUserroleHierachy()
|
||||
{
|
||||
$userrole = User::getUserRoleHierarchy();
|
||||
|
||||
if( $userrole == 0 ) return 0;
|
||||
|
||||
$roleHierarchy = Role::whereRolelevel($userrole)
|
||||
->first()
|
||||
->rolehierarchy;
|
||||
|
||||
return $roleHierarchy;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user