From f33a07c32f8a3206044ffd89deb47cd0bf24f010 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 7 Apr 2023 22:09:56 +0000 Subject: [PATCH] Apply fixes from StyleCI --- app/Http/Livewire/Datatable.php | 4 ++-- app/Models/AcademicYear.php | 10 +++++----- app/Models/Exam.php | 5 ++--- app/Models/School.php | 18 +++++++++--------- app/Models/Timetable.php | 6 +++--- .../AcademicYear/AcademicYearService.php | 13 +++++++------ app/Services/Exam/ExamService.php | 6 +++--- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/Http/Livewire/Datatable.php b/app/Http/Livewire/Datatable.php index 993ed213..cbafee1b 100644 --- a/app/Http/Livewire/Datatable.php +++ b/app/Http/Livewire/Datatable.php @@ -50,10 +50,10 @@ public function mount(string|Builder $model, array $columns, array $filters = [] * * @throws \App\Exceptions\InvalidClassException */ - public function verifyIsModel($model) : bool + public function verifyIsModel($model): bool { if (!is_subclass_of($model, 'Illuminate\Database\Eloquent\Model')) { - throw new InvalidClassException(sprintf('Class %s is not a model', get_class( $model)), 1); + throw new InvalidClassException(sprintf('Class %s is not a model', get_class($model)), 1); } return true; diff --git a/app/Models/AcademicYear.php b/app/Models/AcademicYear.php index 60ffe662..e9ca1dea 100755 --- a/app/Models/AcademicYear.php +++ b/app/Models/AcademicYear.php @@ -2,9 +2,9 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -22,19 +22,19 @@ class AcademicYear extends Model 'school_id', ]; - protected function name() : Attribute + protected function name(): Attribute { return Attribute::make( - get: fn() => "$this->start_year - $this->stop_year", + get: fn () => "$this->start_year - $this->stop_year", ); } - public function school() : BelongsTo + public function school(): BelongsTo { return $this->belongsTo(School::class); } - public function semesters() : HasMany + public function semesters(): HasMany { return $this->hasMany(Semester::class); } diff --git a/app/Models/Exam.php b/app/Models/Exam.php index f3d708ee..14b5b0d9 100755 --- a/app/Models/Exam.php +++ b/app/Models/Exam.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -35,12 +34,12 @@ class Exam extends Model 'publish_result' => 'boolean', ]; - public function semester() : BelongsTo + public function semester(): BelongsTo { return $this->belongsTo(Semester::class); } - public function examSlots() : HasMany + public function examSlots(): HasMany { return $this->hasMany(ExamSlot::class); } diff --git a/app/Models/School.php b/app/Models/School.php index a8e611f6..81331f08 100755 --- a/app/Models/School.php +++ b/app/Models/School.php @@ -2,11 +2,11 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasManyThrough; +use Illuminate\Database\Eloquent\Relations\HasOne; class School extends Model { @@ -17,9 +17,9 @@ class School extends Model ]; /** - * Get all the class groups in the school + * Get all the class groups in the school. */ - public function classGroups() : HasMany + public function classGroups(): HasMany { return $this->hasMany(ClassGroup::class); } @@ -27,7 +27,7 @@ public function classGroups() : HasMany /** * Get all of the users for the School. */ - public function users() : HasMany + public function users(): HasMany { return $this->hasMany(User::class); } @@ -35,7 +35,7 @@ public function users() : HasMany /** * Get all of the MyClasses for the School. */ - public function myClasses() : HasManyThrough + public function myClasses(): HasManyThrough { return $this->hasManyThrough(MyClass::class, ClassGroup::class); } @@ -43,7 +43,7 @@ public function myClasses() : HasManyThrough /** * Get the AcademicYears for the School. */ - public function academicYears() : HasMany + public function academicYears(): HasMany { return $this->hasMany(AcademicYear::class); } @@ -51,7 +51,7 @@ public function academicYears() : HasMany /** * Get the academicYear associated with the School. */ - public function academicYear() : HasOne + public function academicYear(): HasOne { return $this->hasOne(AcademicYear::class, 'id', 'academic_year_id'); } @@ -59,7 +59,7 @@ public function academicYear() : HasOne /** * Get the semester associated with the School. */ - public function semester() : HasOne + public function semester(): HasOne { return $this->hasOne(Semester::class, 'id', 'semester_id'); } diff --git a/app/Models/Timetable.php b/app/Models/Timetable.php index c028379e..d6178a39 100755 --- a/app/Models/Timetable.php +++ b/app/Models/Timetable.php @@ -20,17 +20,17 @@ class Timetable extends Pivot 'my_class_id', ]; - public function semester() : BelongsTo + public function semester(): BelongsTo { return $this->belongsTo(Semester::class); } - public function myClass() : BelongsTo + public function myClass(): BelongsTo { return $this->belongsTo(MyClass::class); } - public function timeSlots() : HasMany + public function timeSlots(): HasMany { return $this->hasMany(TimetableTimeSlot::class, 'timetable_id'); } diff --git a/app/Services/AcademicYear/AcademicYearService.php b/app/Services/AcademicYear/AcademicYearService.php index 42ef0484..392c0b8e 100755 --- a/app/Services/AcademicYear/AcademicYearService.php +++ b/app/Services/AcademicYear/AcademicYearService.php @@ -21,7 +21,7 @@ public function __construct(SchoolService $schoolService) /** * Get all academic years. */ - public function getAllAcademicYears() : Collection|static + public function getAllAcademicYears(): Collection|static { return AcademicYear::where('school_id', auth()->user()->school_id)->get(); } @@ -31,7 +31,7 @@ public function getAllAcademicYears() : Collection|static * *@param int $id */ - public function getAcademicYearById($id) : AcademicYear + public function getAcademicYearById($id): AcademicYear { return AcademicYear::find($id); } @@ -41,7 +41,7 @@ public function getAcademicYearById($id) : AcademicYear * * @param array|Collection $records */ - public function createAcademicYear($records) : AcademicYear + public function createAcademicYear($records): AcademicYear { $records['school_id'] = auth()->user()->school_id; $academicYear = AcademicYear::create($records); @@ -54,7 +54,7 @@ public function createAcademicYear($records) : AcademicYear * * @param array|Collection $records */ - public function updateAcademicYear(AcademicYear $academicYear, $records) : AcademicYear + public function updateAcademicYear(AcademicYear $academicYear, $records): AcademicYear { $academicYear->start_year = $records['start_year']; $academicYear->stop_year = $records['stop_year']; @@ -66,7 +66,7 @@ public function updateAcademicYear(AcademicYear $academicYear, $records) : Acade /** * Delete an academic year. */ - public function deleteAcademicYear(AcademicYear $academicYear) : bool|null + public function deleteAcademicYear(AcademicYear $academicYear): bool|null { return $academicYear->delete(); } @@ -77,7 +77,7 @@ public function deleteAcademicYear(AcademicYear $academicYear) : bool|null * @param int $academicYearId * @param int $schoolId */ - public function setAcademicYear($academicYearId, $schoolId = null) : bool + public function setAcademicYear($academicYearId, $schoolId = null): bool { if (!isset($schoolId)) { $schoolId = auth()->user()->school_id; @@ -86,6 +86,7 @@ public function setAcademicYear($academicYearId, $schoolId = null) : bool $school->academic_year_id = $academicYearId; //set semester id to null $school->semester_id = null; + return $school->save(); } } diff --git a/app/Services/Exam/ExamService.php b/app/Services/Exam/ExamService.php index 6055c234..6c47e6a9 100755 --- a/app/Services/Exam/ExamService.php +++ b/app/Services/Exam/ExamService.php @@ -2,11 +2,11 @@ namespace App\Services\Exam; +use App\Exceptions\EmptyRecordsException; use App\Models\Exam; -use App\Models\User; -use App\Models\Subject; use App\Models\Semester; -use App\Exceptions\EmptyRecordsException; +use App\Models\Subject; +use App\Models\User; use Illuminate\Database\Eloquent\Collection; class ExamService