update: latest changes to multi-tenant branch
This commit is contained in:
@@ -13,14 +13,15 @@ class DesignationController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (Auth::user()->can('manage-designations')) {
|
||||
$query = Designation::with(['department', 'department.branch'])->where(function ($q) {
|
||||
if (Auth::user()->can('manage-any-designations')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-own-designations')) {
|
||||
$q->where('created_by', Auth::id());
|
||||
$user = Auth::user();
|
||||
if ($user->type === 'company' || $user->can('manage-designations') || $user->can('view-designations')) {
|
||||
$query = Designation::with(['department', 'department.branch'])->where(function ($q) use ($user) {
|
||||
if ($user->type === 'company' || $user->can('manage-any-designations') || $user->can('manage-designations') || $user->can('view-designations')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif ($user->can('manage-own-designations')) {
|
||||
$q->where('created_by', $user->id);
|
||||
} else {
|
||||
$q->whereRaw('1 = 0');
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -69,7 +70,8 @@ class DesignationController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
if (Auth::user()->can('create-designations')) {
|
||||
$user = Auth::user();
|
||||
if ($user->type === 'company' || $user->can('create-designations') || $user->can('manage-designations')) {
|
||||
try {
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
|
||||
Reference in New Issue
Block a user