added a comment to User model

This commit is contained in:
mwalbeck 2016-09-09 19:36:48 +02:00
parent bc6183991d
commit 58551fc668

View file

@ -55,6 +55,13 @@ class User extends Authenticatable
return true;
}
/**
*
* Function for deleting user. Checks if it is the user itself,
* a moderator in the same group or an administrator.
* If this is not case, the user will not be deleted.
*
*/
public function deleteUser()
{
if ($this->id == \Auth::user()->id) {
@ -62,7 +69,7 @@ class User extends Authenticatable
return true;
}
if (\Auth::user()->company_id == $this->company_id && \Auth::user()->access_level >= 2) {
if (\Auth::user()->group_id == $this->group_id && \Auth::user()->access_level >= 2) {
$this->delete();
return true;
}
@ -73,6 +80,5 @@ class User extends Authenticatable
}
return false;
}
}