update: latest changes to multi-tenant branch
This commit is contained in:
@@ -15,14 +15,15 @@ class EmployeeContractController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (Auth::user()->can('manage-employee-contracts')) {
|
||||
$query = EmployeeContract::with(['employee', 'contractType', 'approver'])->where(function ($q) {
|
||||
if (Auth::user()->can('manage-any-awards')) {
|
||||
$user = Auth::user();
|
||||
if ($user->type === 'company' || $user->can('manage-employee-contracts') || $user->can('manage-contracts') || $user->can('view-contracts')) {
|
||||
$query = EmployeeContract::with(['employee', 'contractType', 'approver'])->where(function ($q) use ($user) {
|
||||
if ($user->type === 'company' || $user->can('manage-any-employee-contracts') || $user->can('manage-employee-contracts') || $user->can('manage-contracts')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-own-employee-contracts')) {
|
||||
$q->where('created_by', Auth::id())->orWhere('employee_id', Auth::id())->orWhere('approved_by', Auth::id());
|
||||
} elseif ($user->can('manage-own-employee-contracts')) {
|
||||
$q->where('created_by', $user->id)->orWhere('employee_id', $user->id)->orWhere('approved_by', $user->id);
|
||||
} else {
|
||||
$q->whereRaw('1 = 0');
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user