added a comment to User model
This commit is contained in:
parent
bc6183991d
commit
58551fc668
1 changed files with 8 additions and 2 deletions
10
app/User.php
10
app/User.php
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue