Fix Laravel Pint formatting
This commit is contained in:
@@ -15,7 +15,6 @@ use App\Http\Resources\Students\StudentClassSectionResource;
|
||||
use App\Http\Resources\Students\StudentRemovedResource;
|
||||
use App\Http\Resources\Students\StudentScoreCardRowResource;
|
||||
use App\Models\AttendanceRecord;
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\EmergencyContact;
|
||||
use App\Models\Incident;
|
||||
use App\Models\SemesterScore;
|
||||
@@ -82,10 +81,10 @@ class StudentController extends BaseApiController
|
||||
|
||||
$payload = $validator->validated();
|
||||
$parentIds = [];
|
||||
if (!empty($payload['parent_ids'])) {
|
||||
if (! empty($payload['parent_ids'])) {
|
||||
$parentIds = array_values(array_unique(array_map('intval', $payload['parent_ids'])));
|
||||
}
|
||||
if (!empty($payload['parent_id'])) {
|
||||
if (! empty($payload['parent_id'])) {
|
||||
$parentIds[] = (int) $payload['parent_id'];
|
||||
}
|
||||
$parentIds = array_values(array_unique(array_filter($parentIds)));
|
||||
@@ -149,7 +148,7 @@ class StudentController extends BaseApiController
|
||||
public function show(int $studentId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -244,7 +243,7 @@ class StudentController extends BaseApiController
|
||||
if (array_key_exists('allergies', $payload)) {
|
||||
$healthPayload['allergies'] = $payload['allergies'];
|
||||
}
|
||||
if (!empty($healthPayload)) {
|
||||
if (! empty($healthPayload)) {
|
||||
$this->profileService->updateStudent($student->id, $healthPayload);
|
||||
}
|
||||
|
||||
@@ -361,7 +360,7 @@ class StudentController extends BaseApiController
|
||||
public function destroy(int $studentId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -503,8 +502,8 @@ class StudentController extends BaseApiController
|
||||
|
||||
$rows = AttendanceRecord::query()
|
||||
->where('student_id', $studentId)
|
||||
->when(!empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(!empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->when(! empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(! empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->orderBy('school_year', 'desc')
|
||||
->orderBy('semester', 'desc')
|
||||
->get()
|
||||
@@ -535,8 +534,8 @@ class StudentController extends BaseApiController
|
||||
|
||||
$rows = Incident::query()
|
||||
->where('student_id', $studentId)
|
||||
->when(!empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(!empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->when(! empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(! empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->orderByDesc('incident_datetime')
|
||||
->get()
|
||||
->toArray();
|
||||
@@ -566,8 +565,8 @@ class StudentController extends BaseApiController
|
||||
|
||||
$rows = SemesterScore::query()
|
||||
->where('student_id', $studentId)
|
||||
->when(!empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(!empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->when(! empty($payload['school_year']), fn ($q) => $q->where('school_year', $payload['school_year']))
|
||||
->when(! empty($payload['semester']), fn ($q) => $q->where('semester', $payload['semester']))
|
||||
->orderBy('school_year', 'desc')
|
||||
->orderBy('semester', 'desc')
|
||||
->get()
|
||||
@@ -592,12 +591,12 @@ class StudentController extends BaseApiController
|
||||
public function parents(int $studentId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
$parent = null;
|
||||
if (!empty($student->parent_id)) {
|
||||
if (! empty($student->parent_id)) {
|
||||
$parent = User::query()
|
||||
->select(['id', 'firstname', 'lastname', 'email', 'cellphone'])
|
||||
->find((int) $student->parent_id);
|
||||
@@ -613,7 +612,7 @@ class StudentController extends BaseApiController
|
||||
public function emergencyContacts(int $studentId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -621,7 +620,7 @@ class StudentController extends BaseApiController
|
||||
if (Schema::hasColumn('emergency_contacts', 'student_id')) {
|
||||
$query->where('student_id', $studentId);
|
||||
}
|
||||
if (!empty($student->parent_id)) {
|
||||
if (! empty($student->parent_id)) {
|
||||
$query->orWhere('parent_id', $student->parent_id);
|
||||
}
|
||||
|
||||
@@ -640,7 +639,7 @@ class StudentController extends BaseApiController
|
||||
public function addEmergencyContact(Request $request, int $studentId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -683,7 +682,7 @@ class StudentController extends BaseApiController
|
||||
public function updateEmergencyContact(Request $request, int $studentId, int $contactId): JsonResponse
|
||||
{
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -705,7 +704,7 @@ class StudentController extends BaseApiController
|
||||
}
|
||||
|
||||
$contact = EmergencyContact::query()->find($contactId);
|
||||
if (!$contact) {
|
||||
if (! $contact) {
|
||||
return response()->json(['ok' => false, 'message' => 'Contact not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -736,7 +735,7 @@ class StudentController extends BaseApiController
|
||||
}
|
||||
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
@@ -759,14 +758,14 @@ class StudentController extends BaseApiController
|
||||
}
|
||||
|
||||
$student = Student::query()->find($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return response()->json(['ok' => false, 'message' => 'Student not found.'], 404);
|
||||
}
|
||||
|
||||
$file = $request->file('photo');
|
||||
$ext = $file->getClientOriginalExtension() ?: 'jpg';
|
||||
$path = "student-photos/{$studentId}." . strtolower($ext);
|
||||
Storage::disk('public')->putFileAs('student-photos', $file, "{$studentId}." . strtolower($ext));
|
||||
$path = "student-photos/{$studentId}.".strtolower($ext);
|
||||
Storage::disk('public')->putFileAs('student-photos', $file, "{$studentId}.".strtolower($ext));
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
@@ -781,7 +780,7 @@ class StudentController extends BaseApiController
|
||||
$disk = Storage::disk('public');
|
||||
|
||||
foreach ($candidates as $ext) {
|
||||
$path = $base . '.' . $ext;
|
||||
$path = $base.'.'.$ext;
|
||||
if ($disk->exists($path)) {
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
@@ -796,13 +795,14 @@ class StudentController extends BaseApiController
|
||||
private function generateSchoolId(int $studentId): string
|
||||
{
|
||||
$year = (int) date('y');
|
||||
return 'STU' . $year . str_pad((string) $studentId, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
return 'STU'.$year.str_pad((string) $studentId, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function scoreCard(int $studentId): JsonResponse
|
||||
{
|
||||
$result = $this->scoreCardService->scoreCard($studentId);
|
||||
if (!$result['ok']) {
|
||||
if (! $result['ok']) {
|
||||
return response()->json(['ok' => false, 'message' => $result['message'] ?? 'Not found.'], 404);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user