update: latest changes to multi-tenant branch
This commit is contained in:
@@ -22,14 +22,15 @@ class CandidateController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (Auth::user()->can('manage-candidates')) {
|
||||
$query = Candidate::with(['job', 'source', 'referralEmployee'])->where(function ($q) {
|
||||
if (Auth::user()->can('manage-any-candidates')) {
|
||||
$user = Auth::user();
|
||||
if ($user->type === 'company' || $user->can('manage-candidates') || $user->can('view-candidates') || $user->can('manage-recruitment') || $user->can('view-applicant')) {
|
||||
$query = Candidate::with(['job', 'source', 'referralEmployee'])->where(function ($q) use ($user) {
|
||||
if ($user->type === 'company' || $user->can('manage-any-candidates') || $user->can('manage-candidates') || $user->can('manage-recruitment')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-own-candidates')) {
|
||||
$q->where('created_by', Auth::id());
|
||||
} elseif ($user->can('manage-own-candidates')) {
|
||||
$q->where('created_by', $user->id);
|
||||
} else {
|
||||
$q->whereRaw('1 = 0');
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user