create or update skip employee rule
This commit is contained in:
parent
ed444a666e
commit
bd66c98954
@ -67,7 +67,13 @@ class Users extends Controller
|
|||||||
$landing_pages = $u->landing_pages;
|
$landing_pages = $u->landing_pages;
|
||||||
|
|
||||||
$roles = Role::all()->reject(function ($r) {
|
$roles = Role::all()->reject(function ($r) {
|
||||||
return $r->hasPermission('read-client-portal');
|
$status = $r->hasPermission('read-client-portal');
|
||||||
|
|
||||||
|
if ($r->name == 'employee') {
|
||||||
|
$status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
})->pluck('display_name', 'id');
|
})->pluck('display_name', 'id');
|
||||||
|
|
||||||
$companies = user()->companies()->take(setting('default.select_limit'))->get()->sortBy('name')->pluck('name', 'id');
|
$companies = user()->companies()->take(setting('default.select_limit'))->get()->sortBy('name')->pluck('name', 'id');
|
||||||
@ -129,12 +135,21 @@ class Users extends Controller
|
|||||||
if ($user->isCustomer()) {
|
if ($user->isCustomer()) {
|
||||||
// Show only roles with customer permission
|
// Show only roles with customer permission
|
||||||
$roles = Role::all()->reject(function ($r) {
|
$roles = Role::all()->reject(function ($r) {
|
||||||
return !$r->hasPermission('read-client-portal');
|
return ! $r->hasPermission('read-client-portal');
|
||||||
})->pluck('display_name', 'id');
|
})->pluck('display_name', 'id');
|
||||||
|
} else if ($user->isEmployee()) {
|
||||||
|
// Show only roles with employee permission
|
||||||
|
$roles = Role::where('name', 'employee')->get()->pluck('display_name', 'id');
|
||||||
} else {
|
} else {
|
||||||
// Don't show roles with customer permission
|
// Don't show roles with customer permission
|
||||||
$roles = Role::all()->reject(function ($r) {
|
$roles = Role::all()->reject(function ($r) {
|
||||||
return $r->hasPermission('read-client-portal');
|
$status = $r->hasPermission('read-client-portal');
|
||||||
|
|
||||||
|
if ($r->name == 'employee') {
|
||||||
|
$status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
})->pluck('display_name', 'id');
|
})->pluck('display_name', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +240,28 @@ class User extends Authenticatable implements HasLocalePreference
|
|||||||
return $query->wherePermissionIs('read-admin-panel');
|
return $query->wherePermissionIs('read-admin-panel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope to only employees.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeIsEmployee($query)
|
||||||
|
{
|
||||||
|
return $query->whereHasRole('employee');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope to only users.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeIsNotEmployee($query)
|
||||||
|
{
|
||||||
|
return $query->wherePermissionIs('read-admin-panel');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeEmail($query, $email)
|
public function scopeEmail($query, $email)
|
||||||
{
|
{
|
||||||
return $query->where('email', '=', $email);
|
return $query->where('email', '=', $email);
|
||||||
@ -289,6 +311,26 @@ class User extends Authenticatable implements HasLocalePreference
|
|||||||
return (bool) $this->can('read-admin-panel');
|
return (bool) $this->can('read-admin-panel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if user is a employee.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isEmployee()
|
||||||
|
{
|
||||||
|
return (bool) $this->hasRole('employee');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if user is not a employee.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isNotEmployee()
|
||||||
|
{
|
||||||
|
return (bool) ! $this->hasRole('employee');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeSource($query, $source)
|
public function scopeSource($query, $source)
|
||||||
{
|
{
|
||||||
return $query->where($this->qualifyColumn('created_from'), $source);
|
return $query->where($this->qualifyColumn('created_from'), $source);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user