Skip to content

Commit

Permalink
Apply locationable on status editor assignee dropdown
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Oct 6, 2023
1 parent 3472490 commit 4e0d636
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/admin/formwidgets/StatusEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Admin\Classes\BaseFormWidget;
use Admin\Classes\FormField;
use Admin\Facades\AdminAuth;
use Admin\Facades\AdminLocation;
use Admin\Models\Orders_model;
use Admin\Models\Staff_groups_model;
use Admin\Models\Staffs_model;
Expand Down Expand Up @@ -234,9 +235,15 @@ public static function getAssigneeOptions($form, $field)
if (!strlen($groupId = post('groupId', $form->getField('assignee_group_id')->value)))
return [];

return Staffs_model::whereHas('groups', function ($query) use ($groupId) {
$query = Staffs_model::whereHas('groups', function ($query) use ($groupId) {
$query->where('staff_groups.staff_group_id', $groupId);
})->isEnabled()->dropdown('staff_name');
});

if ($locationId = AdminLocation::getId()) {
$query->whereHasLocation($locationId);
}

return $query->isEnabled()->dropdown('staff_name');
}

public static function getAssigneeGroupOptions()
Expand Down

0 comments on commit 4e0d636

Please sign in to comment.