Correction code style
This commit is contained in:
parent
67a02034f1
commit
fb2fda38bb
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,8 @@ class StudentController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected ServiceInterface $service
|
||||
){}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -12,7 +12,8 @@ class TeacherController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected ServiceInterface $service
|
||||
){}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class GradeService implements ServiceInterface
|
||||
{
|
||||
|
||||
public function getAll(): LengthAwarePaginator
|
||||
{
|
||||
return Grade::filter()->paginate(5)->withQueryString();
|
||||
|
@ -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
|
||||
|
@ -8,7 +8,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class SubjectService implements ServiceInterface
|
||||
{
|
||||
|
||||
public function getAll(): LengthAwarePaginator
|
||||
{
|
||||
return Subject::filter()->paginate(5)->withQueryString();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Student;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\User;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
Loading…
Reference in New Issue
Block a user