diff --git a/app/Http/Controllers/GradeController.php b/app/Http/Controllers/GradeController.php index f5f5df3..c998e75 100644 --- a/app/Http/Controllers/GradeController.php +++ b/app/Http/Controllers/GradeController.php @@ -12,7 +12,8 @@ class GradeController extends Controller { public function __construct( protected ServiceInterface $service, - ){} + ) { + } /** * Display a listing of the resource. @@ -46,7 +47,7 @@ class GradeController extends Controller public function show(Grade $grade): View { return view('grades.show', [ - 'grade' => $grade, + 'grade' => $grade, ]); } diff --git a/app/Http/Controllers/StudentController.php b/app/Http/Controllers/StudentController.php index d8fd103..fa76501 100644 --- a/app/Http/Controllers/StudentController.php +++ b/app/Http/Controllers/StudentController.php @@ -13,7 +13,8 @@ class StudentController extends Controller { public function __construct( protected ServiceInterface $service - ){} + ) { + } /** * Display a listing of the resource. diff --git a/app/Http/Controllers/SubjectController.php b/app/Http/Controllers/SubjectController.php index a8911b3..58e670f 100644 --- a/app/Http/Controllers/SubjectController.php +++ b/app/Http/Controllers/SubjectController.php @@ -12,7 +12,8 @@ class SubjectController extends Controller { public function __construct( protected ServiceInterface $service, - ){} + ) { + } /** * Display a listing of the resource. @@ -20,7 +21,7 @@ class SubjectController extends Controller public function index(): View { return view('subjects.index', [ - "subjects" => $this->service->getAll(), + 'subjects' => $this->service->getAll(), ]); } @@ -49,7 +50,7 @@ class SubjectController extends Controller public function show(Subject $subject): View { return view('subjects.show', [ - "subject" => $subject + 'subject' => $subject, ]); } diff --git a/app/Http/Controllers/SubjectTeacherController.php b/app/Http/Controllers/SubjectTeacherController.php index 609c773..1cb6fcc 100644 --- a/app/Http/Controllers/SubjectTeacherController.php +++ b/app/Http/Controllers/SubjectTeacherController.php @@ -13,7 +13,8 @@ class SubjectTeacherController extends Controller { public function __construct( protected ServiceInterface $service, - ){} + ) { + } public function create(Teacher $teacher): View { @@ -25,7 +26,7 @@ class SubjectTeacherController extends Controller public function store(SubjectTeacherPostRequest $request, Teacher $teacher): RedirectResponse { - return redirect()->route('teachers.show', $this->service->create($request->validated(), $teacher)); + return redirect()->route('teachers.show', $this->service->create($request->validated(), $teacher)); } public function edit(Teacher $teacher, Subject $subject): View diff --git a/app/Http/Controllers/TeacherController.php b/app/Http/Controllers/TeacherController.php index 1a18cce..f82ffda 100644 --- a/app/Http/Controllers/TeacherController.php +++ b/app/Http/Controllers/TeacherController.php @@ -12,7 +12,8 @@ class TeacherController extends Controller { public function __construct( protected ServiceInterface $service - ){} + ) { + } /** * Display a listing of the resource. diff --git a/app/Http/Requests/StudentPostRequest.php b/app/Http/Requests/StudentPostRequest.php index 71bc504..132c34d 100644 --- a/app/Http/Requests/StudentPostRequest.php +++ b/app/Http/Requests/StudentPostRequest.php @@ -2,8 +2,6 @@ namespace App\Http\Requests; -use App\Enums\RoleEnum; -use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; class StudentPostRequest extends FormRequest diff --git a/app/Http/Requests/TeacherPostRequest.php b/app/Http/Requests/TeacherPostRequest.php index 932d7d5..e3aea8a 100644 --- a/app/Http/Requests/TeacherPostRequest.php +++ b/app/Http/Requests/TeacherPostRequest.php @@ -2,8 +2,6 @@ namespace App\Http\Requests; -use App\Enums\RoleEnum; -use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; class TeacherPostRequest extends FormRequest diff --git a/app/Models/Student.php b/app/Models/Student.php index 7e97ab8..43844ae 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -2,12 +2,13 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Builder; 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\MorphOne; -use Illuminate\Database\Eloquent\Builder; + class Student extends Model { use HasFactory; @@ -33,7 +34,7 @@ class Student extends Model public function scopeFilter(Builder $query): void { $name = request('name'); - $query->when($name, function (Builder $query, $name){ + $query->when($name, function (Builder $query, $name) { $query->whereRaw('CONCAT (name, \' \', surname, \' \', patronymic) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (name, \' \', patronymic, \' \', surname) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (surname, \' \', name, \' \', patronymic) ilike ?', ["$name%"]); @@ -46,7 +47,7 @@ class Student extends Model public function fio(): Attribute { return Attribute::make( - get: fn () => $this->last_name . " " . $this->name . " " . $this->middle_name, + get: fn () => $this->last_name.' '.$this->name.' '.$this->middle_name, ); } } diff --git a/app/Models/Teacher.php b/app/Models/Teacher.php index c5cbf24..f18c015 100644 --- a/app/Models/Teacher.php +++ b/app/Models/Teacher.php @@ -2,12 +2,13 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\MorphOne; -use Illuminate\Database\Eloquent\Builder; + class Teacher extends Model { use HasFactory; @@ -37,7 +38,7 @@ class Teacher extends Model public function scopeFilter(Builder $query): void { $name = request('name'); - $query->when($name, function (Builder $query, $name){ + $query->when($name, function (Builder $query, $name) { $query->whereRaw('CONCAT (name, \' \', surname, \' \', patronymic) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (name, \' \', patronymic, \' \', surname) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (surname, \' \', name, \' \', patronymic) ilike ?', ["$name%"]); @@ -50,7 +51,7 @@ class Teacher extends Model public function fio(): Attribute { return Attribute::make( - get: fn () => $this->last_name . " " . $this->name . " " . $this->middle_name, + get: fn () => $this->last_name.' '.$this->name.' '.$this->middle_name, ); } } diff --git a/app/Services/GradeService.php b/app/Services/GradeService.php index 38ad047..6ab6453 100644 --- a/app/Services/GradeService.php +++ b/app/Services/GradeService.php @@ -8,7 +8,6 @@ use Illuminate\Pagination\LengthAwarePaginator; class GradeService implements ServiceInterface { - public function getAll(): LengthAwarePaginator { return Grade::filter()->paginate(5)->withQueryString(); diff --git a/app/Services/StudentService.php b/app/Services/StudentService.php index ac4d0b0..6aafb74 100644 --- a/app/Services/StudentService.php +++ b/app/Services/StudentService.php @@ -3,9 +3,7 @@ namespace App\Services; use App\Models\Student; -use App\Models\Teacher; use App\Models\User; -use Illuminate\Database\Eloquent\Model; use Illuminate\Pagination\LengthAwarePaginator; class StudentService implements ServiceInterface diff --git a/app/Services/SubjectService.php b/app/Services/SubjectService.php index c857584..6687465 100644 --- a/app/Services/SubjectService.php +++ b/app/Services/SubjectService.php @@ -8,7 +8,6 @@ use Illuminate\Pagination\LengthAwarePaginator; class SubjectService implements ServiceInterface { - public function getAll(): LengthAwarePaginator { return Subject::filter()->paginate(5)->withQueryString(); diff --git a/app/Services/SubjectTeacherService.php b/app/Services/SubjectTeacherService.php index c0dbe93..d5ea630 100644 --- a/app/Services/SubjectTeacherService.php +++ b/app/Services/SubjectTeacherService.php @@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model; class SubjectTeacherService implements ServiceInterface { - public function getAll(Teacher $teacher = null): Collection + public function getAll(?Teacher $teacher = null): Collection { return $teacher->subjects; } @@ -19,14 +19,14 @@ class SubjectTeacherService implements ServiceInterface return Subject::all(); } - public function create(array $data, Model $model = null): Teacher + public function create(array $data, ?Model $model = null): Teacher { $model->subjects()->syncWithoutDetaching($data['subject_id']); return $model; } - public function update(Model $model, array $data, Model $subject = null): Teacher + public function update(Model $model, array $data, ?Model $subject = null): Teacher { $model->subjects()->detach($subject->id); $model->subjects()->attach($data['subject_id']); @@ -34,7 +34,7 @@ class SubjectTeacherService implements ServiceInterface return $model; } - public function delete(Model $model, Model $subject = null): Teacher + public function delete(Model $model, ?Model $subject = null): Teacher { $model->subjects()->detach($subject); diff --git a/app/Services/TeacherService.php b/app/Services/TeacherService.php index 374c995..ea04740 100644 --- a/app/Services/TeacherService.php +++ b/app/Services/TeacherService.php @@ -2,7 +2,6 @@ namespace App\Services; -use App\Models\Student; use App\Models\Teacher; use App\Models\User; use Illuminate\Pagination\LengthAwarePaginator;