Fix Laravel Pint formatting
This commit is contained in:
+42
-32
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -12,6 +11,7 @@ use Illuminate\Support\Facades\DB;
|
||||
class Student extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'students';
|
||||
|
||||
/**
|
||||
@@ -39,15 +39,15 @@ class Student extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'school_id' => 'string',
|
||||
'age' => 'integer',
|
||||
'photo_consent' => 'boolean',
|
||||
'is_new' => 'boolean',
|
||||
'parent_id' => 'integer',
|
||||
'tuition_paid' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'dob' => 'date',
|
||||
'registration_date' => 'date',
|
||||
'school_id' => 'string',
|
||||
'age' => 'integer',
|
||||
'photo_consent' => 'boolean',
|
||||
'is_new' => 'boolean',
|
||||
'parent_id' => 'integer',
|
||||
'tuition_paid' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'dob' => 'date',
|
||||
'registration_date' => 'date',
|
||||
'year_of_registration' => 'integer',
|
||||
];
|
||||
|
||||
@@ -97,6 +97,7 @@ class Student extends BaseModel
|
||||
if ($schoolYear === null || strtolower(trim($schoolYear)) === 'all' || trim($schoolYear) === '') {
|
||||
return $q;
|
||||
}
|
||||
|
||||
return $q->where('school_year', $schoolYear);
|
||||
}
|
||||
|
||||
@@ -213,6 +214,7 @@ class Student extends BaseModel
|
||||
public static function getStudentSchoolIdByStudentId(int $studentId): ?string
|
||||
{
|
||||
$v = static::query()->where('id', $studentId)->value('school_id');
|
||||
|
||||
return $v !== null ? (string) $v : null;
|
||||
}
|
||||
|
||||
@@ -232,12 +234,16 @@ class Student extends BaseModel
|
||||
public static function getFullNameById($studentId): ?array
|
||||
{
|
||||
$student = static::query()->find($studentId);
|
||||
if (!$student) return null;
|
||||
if (! $student) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$first = (string) ($student->firstname ?? '');
|
||||
$last = (string) ($student->lastname ?? '');
|
||||
$last = (string) ($student->lastname ?? '');
|
||||
|
||||
if ($first === '' && $last === '') return null;
|
||||
if ($first === '' && $last === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ['firstname' => $first, 'lastname' => $last];
|
||||
}
|
||||
@@ -245,7 +251,7 @@ class Student extends BaseModel
|
||||
/** legacy: getFullName($student array) */
|
||||
public static function getFullName(array $student): string
|
||||
{
|
||||
return trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''));
|
||||
return trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? ''));
|
||||
}
|
||||
|
||||
/** legacy: getLastRegistrationDate($ParentId) */
|
||||
@@ -272,7 +278,9 @@ class Student extends BaseModel
|
||||
->pluck('student_id')
|
||||
->all();
|
||||
|
||||
if (empty($studentIds)) return [];
|
||||
if (empty($studentIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return static::query()
|
||||
->whereIn('id', $studentIds)
|
||||
@@ -340,7 +348,9 @@ class Student extends BaseModel
|
||||
*/
|
||||
public static function getStudentInfoByClassSectionId(int $classSectionId, ?string $semester = null, ?string $schoolYear = null, ?int $actorId = null): array
|
||||
{
|
||||
if ($classSectionId <= 0) return [];
|
||||
if ($classSectionId <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$q = DB::table('students')
|
||||
->selectRaw('students.id AS student_id, students.school_id, students.firstname, students.lastname, sc.class_section_id')
|
||||
@@ -375,22 +385,22 @@ class Student extends BaseModel
|
||||
$req = $updating ? 'sometimes' : 'required';
|
||||
|
||||
return [
|
||||
'school_id' => ['nullable', 'integer', 'min:1'],
|
||||
'firstname' => [$req, 'string', 'max:120'],
|
||||
'lastname' => [$req, 'string', 'max:120'],
|
||||
'dob' => ['nullable', 'date'],
|
||||
'age' => ['nullable', 'integer', 'min:0'],
|
||||
'gender' => ['nullable', 'string', 'max:20'],
|
||||
'registration_grade' => ['nullable', 'string', 'max:50'],
|
||||
'photo_consent' => ['nullable', 'boolean'],
|
||||
'is_new' => ['nullable', 'boolean'],
|
||||
'parent_id' => ['nullable', 'integer'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'registration_date' => ['nullable', 'date'],
|
||||
'tuition_paid' => ['nullable', 'boolean'],
|
||||
'year_of_registration'=> ['nullable', 'integer', 'min:0'],
|
||||
'rfid_tag' => ['nullable', 'string', 'max:120'],
|
||||
'is_active' => ['nullable', 'boolean'],
|
||||
'school_id' => ['nullable', 'integer', 'min:1'],
|
||||
'firstname' => [$req, 'string', 'max:120'],
|
||||
'lastname' => [$req, 'string', 'max:120'],
|
||||
'dob' => ['nullable', 'date'],
|
||||
'age' => ['nullable', 'integer', 'min:0'],
|
||||
'gender' => ['nullable', 'string', 'max:20'],
|
||||
'registration_grade' => ['nullable', 'string', 'max:50'],
|
||||
'photo_consent' => ['nullable', 'boolean'],
|
||||
'is_new' => ['nullable', 'boolean'],
|
||||
'parent_id' => ['nullable', 'integer'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'registration_date' => ['nullable', 'date'],
|
||||
'tuition_paid' => ['nullable', 'boolean'],
|
||||
'year_of_registration' => ['nullable', 'integer', 'min:0'],
|
||||
'rfid_tag' => ['nullable', 'string', 'max:120'],
|
||||
'is_active' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user