Skip to content

Commit

Permalink
chore: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-canyon authored and github-actions[bot] committed Oct 14, 2024
1 parent a7f167f commit 848473d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->modifyQueryUsing(function($query){
->modifyQueryUsing(function ($query) {
$query->when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $q) {
return $q->whereHas('priority.type.managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public function form(Form $form): Form
Grid::make()
->schema([
Select::make('type_id')
->options(ServiceRequestType::when(!auth()->user()->hasRole('authorization.super_admin'),function(Builder $query){
->options(ServiceRequestType::when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $query) {
$query->whereHas('managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
})->orWhereHas('auditors', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
});
})
->pluck('name', 'id'))
->pluck('name', 'id'))
->afterStateUpdated(fn (Set $set) => $set('priority_id', null))
->label('Type')
->required()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function form(Form $form): Form
fn (ServiceRequest $record) => ServiceRequestType::withTrashed()
->whereKey($record->priority?->type_id)
->orWhereNull('deleted_at')
->when(!auth()->user()->hasRole('authorization.super_admin'),function(Builder $query){
->when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $query) {
$query->whereHas('managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
})->orWhereHas('auditors', function (Builder $query): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

namespace AidingApp\ServiceManagement\Filament\Resources\ServiceRequestResource\Pages;

use AidingApp\Assistant\Models\PromptType;
use Filament\Tables\Table;
use Filament\Actions\CreateAction;
use AidingApp\Contact\Models\Contact;
Expand All @@ -46,6 +45,7 @@
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Notifications\Notification;
use App\Filament\Tables\Columns\IdColumn;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Filters\SelectFilter;
Expand All @@ -58,7 +58,6 @@
use AidingApp\ServiceManagement\Models\ServiceRequestPriority;
use AidingApp\ServiceManagement\Enums\SystemServiceRequestClassification;
use AidingApp\ServiceManagement\Filament\Resources\ServiceRequestResource;
use Filament\Notifications\Notification;

class ListServiceRequests extends ListRecords
{
Expand All @@ -77,13 +76,13 @@ public function table(Table $table): Table
],
'status',
])
->when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $q) {
return $q->whereHas('priority.type.managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
})->orWhereHas('priority.type.auditors', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
});
}))
->when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $q) {
return $q->whereHas('priority.type.managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
})->orWhereHas('priority.type.auditors', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
});
}))
->columns([
IdColumn::make(),
TextColumn::make('service_request_number')
Expand Down Expand Up @@ -152,7 +151,7 @@ public function table(Table $table): Table
->action(function ($records) {
$deletedRecordsCount = ServiceRequest::query()
->whereKey($records)
->when(!auth()->user()->hasRole('authorization.super_admin'), function (Builder $q) {
->when(! auth()->user()->hasRole('authorization.super_admin'), function (Builder $q) {
return $q->whereHas('priority.type.managers', function (Builder $query): void {
$query->where('teams.id', auth()->user()->teams()->first()?->getKey());
})->orWhereHas('priority.type.auditors', function (Builder $query): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public function create(Authenticatable $authenticatable): Response
if (! auth()->user()->hasRole('authorization.super_admin')) {
$team = auth()->user()->teams()->first();

if (!$team?->managableServiceRequestTypes()->exists() && !$team?->auditableServiceRequestTypes()->exists()) {
if (! $team?->managableServiceRequestTypes()->exists() && ! $team?->auditableServiceRequestTypes()->exists()) {
return Response::deny("You don't have permission to view this service request because you're not an auditor or manager.");
}
}

return $authenticatable->canOrElse(
abilities: 'service_request.create',
denyResponse: 'You do not have permission to create service requests.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/

use App\Models\User;
use AidingApp\Team\Models\Team;

use function Tests\asSuperAdmin;

Expand All @@ -53,11 +54,10 @@
use function Pest\Laravel\assertDatabaseMissing;

use AidingApp\ServiceManagement\Models\ServiceRequest;
use AidingApp\ServiceManagement\Models\ServiceRequestType;
use AidingApp\ServiceManagement\Filament\Resources\ServiceRequestResource;
use AidingApp\ServiceManagement\Tests\RequestFactories\CreateServiceRequestRequestFactory;
use AidingApp\ServiceManagement\Filament\Resources\ServiceRequestResource\Pages\CreateServiceRequest;
use AidingApp\ServiceManagement\Models\ServiceRequestType;
use AidingApp\Team\Models\Team;

test('A successful action on the CreateServiceRequest page', function () {
asSuperAdmin()
Expand Down Expand Up @@ -153,7 +153,6 @@
->get(
ServiceRequestResource::getUrl('create')
)->assertForbidden();


livewire(CreateServiceRequest::class)
->assertForbidden();
Expand Down Expand Up @@ -263,8 +262,7 @@
expect($serviceRequest->division->id)->toEqual($request['division_id']);
});

test('cannot create service requests if user is not an auditor or manager of the service request type',function(){

test('cannot create service requests if user is not an auditor or manager of the service request type', function () {
$settings = app(LicenseSettings::class);

$settings->data->addons->serviceManagement = false;
Expand Down Expand Up @@ -298,5 +296,4 @@
->get(
ServiceRequestResource::getUrl('create')
)->assertForbidden();

});
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@
*/

use App\Models\User;
use AidingApp\Team\Models\Team;

use function Tests\asSuperAdmin;

use App\Settings\LicenseSettings;

use function Pest\Laravel\actingAs;
use function Pest\Livewire\livewire;

use AidingApp\Contact\Models\Contact;

use function Pest\Laravel\assertDatabaseHas;

use Illuminate\Support\Facades\Notification;
use AidingApp\Authorization\Enums\LicenseType;
use AidingApp\Contact\Models\Contact;
use AidingApp\ServiceManagement\Models\ServiceRequest;
use AidingApp\ServiceManagement\Models\ServiceRequestType;
use AidingApp\ServiceManagement\Models\ServiceRequestStatus;
Expand All @@ -56,7 +59,6 @@
use AidingApp\ServiceManagement\Notifications\SendClosedServiceFeedbackNotification;
use AidingApp\ServiceManagement\Tests\RequestFactories\EditServiceRequestRequestFactory;
use AidingApp\ServiceManagement\Filament\Resources\ServiceRequestResource\Pages\EditServiceRequest;
use AidingApp\Team\Models\Team;

test('A successful action on the EditServiceRequest page', function () {
$serviceRequest = ServiceRequest::factory([
Expand Down Expand Up @@ -437,4 +439,4 @@
livewire(EditServiceRequest::class, [
'record' => $serviceRequest->getRouteKey(),
])->assertForbidden();
});
});

0 comments on commit 848473d

Please sign in to comment.