add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -9,7 +9,6 @@ use App\Http\Requests\Staff\StaffUpdateRequest;
use App\Http\Resources\Staff\StaffCollection;
use App\Http\Resources\Staff\StaffResource;
use App\Models\Staff;
use App\Models\User;
use App\Services\Staff\StaffCommandService;
use App\Services\Staff\StaffQueryService;
use Illuminate\Http\JsonResponse;
@@ -48,12 +47,12 @@ class StaffController extends BaseApiController
public function show(int $id): JsonResponse
{
$staff = $this->queryService->find($id);
if (! $staff) {
if (!$staff) {
return $this->error('Staff member not found.', Response::HTTP_NOT_FOUND);
}
$this->authorize('view', $staff);
$staff->school_id = User::getSchoolIdByUserId((int) ($staff->user_id ?? 0));
$staff->school_id = \App\Models\User::getSchoolIdByUserId((int) ($staff->user_id ?? 0));
return $this->success([
'staff' => new StaffResource($staff),
@@ -67,8 +66,7 @@ class StaffController extends BaseApiController
try {
$staff = $this->commandService->create($request->validated());
} catch (\Throwable $e) {
Log::error('Staff create failed: '.$e->getMessage());
Log::error('Staff create failed: ' . $e->getMessage());
return $this->error($e->getMessage(), Response::HTTP_BAD_REQUEST);
}
@@ -80,7 +78,7 @@ class StaffController extends BaseApiController
public function update(StaffUpdateRequest $request, int $id): JsonResponse
{
$staff = $this->queryService->find($id);
if (! $staff) {
if (!$staff) {
return $this->error('Staff member not found.', Response::HTTP_NOT_FOUND);
}
@@ -89,8 +87,7 @@ class StaffController extends BaseApiController
try {
$updated = $this->commandService->update($staff, $request->validated());
} catch (\Throwable $e) {
Log::error('Staff update failed: '.$e->getMessage());
Log::error('Staff update failed: ' . $e->getMessage());
return $this->error('Unable to update staff.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
@@ -102,7 +99,7 @@ class StaffController extends BaseApiController
public function destroy(int $id): JsonResponse
{
$staff = $this->queryService->find($id);
if (! $staff) {
if (!$staff) {
return $this->error('Staff member not found.', Response::HTTP_NOT_FOUND);
}
@@ -111,12 +108,11 @@ class StaffController extends BaseApiController
try {
$deleted = $this->commandService->delete($staff);
} catch (\Throwable $e) {
Log::error('Staff delete failed: '.$e->getMessage());
Log::error('Staff delete failed: ' . $e->getMessage());
return $this->error('Unable to delete staff.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
if (! $deleted) {
if (!$deleted) {
return $this->error('Unable to delete staff.', Response::HTTP_INTERNAL_SERVER_ERROR);
}