Skip to content

Commit

Permalink
Merge pull request #303 from yungifez/analysis-O3g4vW
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
yungifez authored Apr 7, 2023
2 parents 72dd69c + f33a07c commit d181db3
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/Http/Livewire/Datatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions app/Models/AcademicYear.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions app/Models/Exam.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions app/Models/School.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -17,49 +17,49 @@ 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);
}

/**
* Get all of the users for the School.
*/
public function users() : HasMany
public function users(): HasMany
{
return $this->hasMany(User::class);
}

/**
* Get all of the MyClasses for the School.
*/
public function myClasses() : HasManyThrough
public function myClasses(): HasManyThrough
{
return $this->hasManyThrough(MyClass::class, ClassGroup::class);
}

/**
* Get the AcademicYears for the School.
*/
public function academicYears() : HasMany
public function academicYears(): HasMany
{
return $this->hasMany(AcademicYear::class);
}

/**
* Get the academicYear associated with the School.
*/
public function academicYear() : HasOne
public function academicYear(): HasOne
{
return $this->hasOne(AcademicYear::class, 'id', 'academic_year_id');
}

/**
* Get the semester associated with the School.
*/
public function semester() : HasOne
public function semester(): HasOne
{
return $this->hasOne(Semester::class, 'id', 'semester_id');
}
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Timetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
13 changes: 7 additions & 6 deletions app/Services/AcademicYear/AcademicYearService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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'];
Expand All @@ -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();
}
Expand All @@ -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;
Expand All @@ -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();
}
}
6 changes: 3 additions & 3 deletions app/Services/Exam/ExamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d181db3

Please sign in to comment.