Task-11 #12

Merged
klllst merged 3 commits from feature/task-11 into develop 2024-06-24 17:36:55 +04:00
23 changed files with 344 additions and 109 deletions

View File

@ -4,6 +4,8 @@ namespace App\Http\Controllers;
use App\Http\Requests\GradePostRequest; use App\Http\Requests\GradePostRequest;
use App\Models\Grade; use App\Models\Grade;
use App\Services\FileService;
use App\Services\GradeService;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\View\View; use Illuminate\View\View;
@ -12,14 +14,14 @@ class GradeController extends Controller
/** /**
* Display a listing of the resource. * Display a listing of the resource.
*/ */
public function index(): View public function index(GradeService $service): View
{ {
if(request()->user()->cannot('viewAny', Grade::class)) { if(request()->user()->cannot('viewAny', Grade::class)) {
abort(403); abort(403);
} }
return view('grades.index', [ return view('grades.index', [
'grades' => Grade::filter()->paginate(5)->withQueryString(), 'grades' => $service->getGrades(),
]); ]);
} }
@ -96,9 +98,13 @@ class GradeController extends Controller
if(request()->user()->cannot('delete', Grade::class)) { if(request()->user()->cannot('delete', Grade::class)) {
abort(403); abort(403);
} }
$grade->delete(); $grade->delete();
return redirect()->route('grades.index'); return redirect()->route('grades.index');
} }
public function listStudents(Grade $grade, FileService $fileService)
{
return $fileService->exportStudents($grade);
}
} }

View File

@ -7,6 +7,7 @@ use App\Enums\TypeLesson;
use App\Http\Requests\LessonPostRequest; use App\Http\Requests\LessonPostRequest;
use App\Models\Grade; use App\Models\Grade;
use App\Models\Lesson; use App\Models\Lesson;
use App\Services\LessonService;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\View\View; use Illuminate\View\View;
@ -22,14 +23,14 @@ class LessonController extends Controller
/** /**
* Display a listing of the resource. * Display a listing of the resource.
*/ */
public function index(Grade $grade): View public function index(Grade $grade, LessonService $service): View
{ {
if(request()->user()->cannot('viewAny', $grade)) { if(request()->user()->cannot('viewAny', $grade)) {
abort(403); abort(403);
} }
return view('grade-lesson.index', [ return view('grade-lesson.index', [
'lessons' => $grade->lessons()->filter()->get(), 'lessons' => $service->getLessons($grade),
'grade' => $grade, 'grade' => $grade,
'subjects' => $grade->subjects, 'subjects' => $grade->subjects,
]); ]);

View File

@ -2,7 +2,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Models\Student; use App\Models\Teacher;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -17,7 +17,7 @@ class TeacherAction
*/ */
public function handle(Request $request, Closure $next): Response public function handle(Request $request, Closure $next): Response
{ {
if (Auth::user()->userable_type != Student::class) { if (Auth::user()->userable_type != Teacher::class) {
abort(403); abort(403);
} }

View File

@ -2,7 +2,9 @@
namespace App\Http\Requests; namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StudentPostRequest extends FormRequest class StudentPostRequest extends FormRequest
{ {
@ -27,7 +29,7 @@ class StudentPostRequest extends FormRequest
'middle_name' => 'required|max:255', 'middle_name' => 'required|max:255',
'birthday' => 'required|date', 'birthday' => 'required|date',
'grade_id' => 'required|exists:grades,id', 'grade_id' => 'required|exists:grades,id',
'email' => 'required|max:255|lowercase|unique:users,email', 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('student')?->user->id)],
'password' => 'required|max:255', 'password' => 'required|max:255',
]; ];
} }

View File

@ -2,7 +2,9 @@
namespace App\Http\Requests; namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class TeacherPostRequest extends FormRequest class TeacherPostRequest extends FormRequest
{ {
@ -26,7 +28,7 @@ class TeacherPostRequest extends FormRequest
'last_name' => 'required|max:255', 'last_name' => 'required|max:255',
'middle_name' => 'required|max:255', 'middle_name' => 'required|max:255',
'birthday' => 'required|date', 'birthday' => 'required|date',
'email' => 'required|max:255|lowercase|unique:users,email', 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->route('teacher')?->user->id)],
'password' => 'required|max:255', 'password' => 'required|max:255',
]; ];
} }

View File

@ -5,6 +5,7 @@ namespace App\Policies;
use App\Models\Admin; use App\Models\Admin;
use App\Models\Grade; use App\Models\Grade;
use App\Models\Student; use App\Models\Student;
use App\Models\Teacher;
use App\Models\User; use App\Models\User;
class GradePolicy class GradePolicy
@ -48,4 +49,14 @@ class GradePolicy
{ {
return $user->userable_type == Admin::class; return $user->userable_type == Admin::class;
} }
public function journal(User $user)
{
return $user->userable_type == Teacher::class;
}
public function list(User $user)
{
return $user->userable_type == Teacher::class;
}
} }

View File

@ -31,7 +31,7 @@ class LessonPolicy
*/ */
public function create(User $user): bool public function create(User $user): bool
{ {
return $user->userable_type == Admin::class; return $user->userable_type != Student::class;
} }
/** /**
@ -39,7 +39,7 @@ class LessonPolicy
*/ */
public function update(User $user, Lesson $lesson): bool public function update(User $user, Lesson $lesson): bool
{ {
return $user->userable_type == Admin::class; return $user->userable_type != Student::class;
} }
/** /**
@ -47,6 +47,6 @@ class LessonPolicy
*/ */
public function delete(User $user, Lesson $lesson): bool public function delete(User $user, Lesson $lesson): bool
{ {
return $user->userable_type == Admin::class; return $user->userable_type != Student::class;
} }
} }

View File

@ -21,7 +21,7 @@ class StudentPolicy
*/ */
public function view(User $user, Student $student): bool public function view(User $user, Student $student): bool
{ {
return $user->userable_type != Student::class; return $user->userable_type == Admin::class;
} }
/** /**
@ -29,7 +29,7 @@ class StudentPolicy
*/ */
public function create(User $user): bool public function create(User $user): bool
{ {
return $user->userable_type != Admin::class; return $user->userable_type == Admin::class;
} }
/** /**
@ -37,7 +37,7 @@ class StudentPolicy
*/ */
public function update(User $user, Student $student): bool public function update(User $user, Student $student): bool
{ {
return $user->userable_type != Admin::class; return $user->userable_type == Admin::class;
} }
/** /**
@ -45,6 +45,11 @@ class StudentPolicy
*/ */
public function delete(User $user, Student $student): bool public function delete(User $user, Student $student): bool
{ {
return $user->userable_type != Admin::class; return $user->userable_type == Admin::class;
}
public function debts(User $user): bool
{
return $user->userable_type == Student::class;
} }
} }

View File

@ -3,11 +3,17 @@
namespace App\Policies; namespace App\Policies;
use App\Models\Admin; use App\Models\Admin;
use App\Models\Student;
use App\Models\Subject; use App\Models\Subject;
use App\Models\Teacher;
use App\Models\User; use App\Models\User;
class SubjectPolicy class SubjectPolicy
{ {
public function viewAny(User $user): bool
{
return $user->userable_type != Teacher::class;
}
/** /**
* Determine whether the user can create models. * Determine whether the user can create models.
*/ */
@ -31,4 +37,9 @@ class SubjectPolicy
{ {
return $user->userable_type == Admin::class; return $user->userable_type == Admin::class;
} }
public function scores(User $user, Subject $subject): bool
{
return $user->userable_type == Student::class;
}
} }

View File

@ -48,4 +48,9 @@ class TeacherPolicy
{ {
return $user->userable_type == Admin::class; return $user->userable_type == Admin::class;
} }
public function teacherSubjects(User $user, Teacher $teacher): bool
{
return $user->userable_type == Student::class;
}
} }

View File

@ -2,6 +2,7 @@
namespace App\Services; namespace App\Services;
use App\Models\Grade;
use Barryvdh\DomPDF\Facade\Pdf; use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -24,4 +25,23 @@ class FileService
return Pdf::loadView('subjects.pdf', ['subjects' => $listSubjects])->download('Предметы.pdf'); return Pdf::loadView('subjects.pdf', ['subjects' => $listSubjects])->download('Предметы.pdf');
} }
public function exportStudents(Grade $grade)
{
$excellentStudents = $this->getMinScore($grade, 5);
$goodStudents = $this->getMinScore($grade, 4);
return Pdf::loadView('grades.list-students', [
'excellentStudents' => $excellentStudents,
'goodStudents' => $goodStudents,
])->download('Студенты.pdf');
}
public function getMinScore(Grade $grade, $minScore)
{
return $grade->students->filter(function ($student) use ($minScore) {
return $student->lessons->min('pivot.score') == $minScore;
});
}
} }

View File

@ -0,0 +1,23 @@
<?php
namespace App\Services;
use App\Models\Grade;
use App\Models\Teacher;
use Illuminate\Support\Facades\Auth;
class GradeService
{
public function getGrades()
{
if (Auth::user()->userable_type == Teacher::class) {
return Grade::join('grade_teacher', 'grade_teacher.grade_id', '=', 'grades.id')
->where('grade_teacher.teacher_id', Auth::user()->userable_id)
->filter()
->paginate(5)
->withQueryString();
}
return Grade::filter()->paginate(5)->withQueryString();
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Services;
use App\Models\Grade;
use App\Models\Teacher;
use Illuminate\Support\Facades\Auth;
class LessonService
{
public function getLessons(Grade $grade)
{
if (Auth::user()->userable_type == Teacher::class) {
return $grade
->lessons()
->where('teacher_id', Auth::user()->userable_id)
->filter()
->get();
}
return $grade->lessons()->filter()->get();
}
}

View File

@ -14,7 +14,7 @@
<select id="type" name="type" class="form-select" required> <select id="type" name="type" class="form-select" required>
<option value="">Выберите тип деятельности</option> <option value="">Выберите тип деятельности</option>
@foreach($types as $type) @foreach($types as $type)
<option value="{{ $type }}" {{ isset($lesson) && $lesson->type == $type ? 'selected' : old('type') }}> <option value="{{ $type }}" {{ isset($lesson) && $lesson->type == $type->value ? 'selected' : old('type') }}>
{{ $type }} {{ $type }}
</option> </option>
@endforeach @endforeach
@ -36,7 +36,7 @@
<textarea class="form-control" id="description" name="description" rows="5" >{{ isset($lesson) ? $lesson->description : old('description') }}</textarea> <textarea class="form-control" id="description" name="description" rows="5" >{{ isset($lesson) ? $lesson->description : old('description') }}</textarea>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="lesson_date" class="form-label">Дата рождения:</label> <label for="lesson_date" class="form-label">Дата занятия:</label>
<input type="date" id="lesson_date" name="lesson_date" class="form-control" value="{{ isset($lesson) ? $lesson->lesson_date : old('lesson_date') }}" required> <input type="date" id="lesson_date" name="lesson_date" class="form-control" value="{{ isset($lesson) ? $lesson->lesson_date : old('lesson_date') }}" required>
</div> </div>
<input type="hidden" name="grade_id" value="{{ $grade->id }}"> <input type="hidden" name="grade_id" value="{{ $grade->id }}">

View File

@ -1,4 +1,4 @@
`@extends('layouts.application') @extends('layouts.application')
@section('content') @section('content')
<div class="container col-md-5"> <div class="container col-md-5">
@ -53,5 +53,3 @@
</div> </div>
</div> </div>
@endsection @endsection
`

View File

@ -41,19 +41,30 @@
<a href="{{ route('grades.lessons.index', $grade) }}" class="btn btn-primary">Занятия</a> <a href="{{ route('grades.lessons.index', $grade) }}" class="btn btn-primary">Занятия</a>
</div> </div>
</td> </td>
<td> @can('list', \App\Models\Grade::class)
<div> <td>
<a href="{{ route('grades.edit', $grade) }}" class="btn btn-warning">Редактировать</a> <div>
</div> <a href="{{ route('list-students', $grade) }}" class="btn btn-info">Списки учеников</a>
</td> </div>
<td> </td>
<form action="{{ route('grades.destroy', $grade) }}" method="POST" @endcan
style="display: inline-block;"> @can('update', $grade)
@csrf <td>
@method('DELETE') <div>
<button type="submit" class="btn btn-danger">Удалить</button> <a href="{{ route('grades.edit', $grade) }}" class="btn btn-warning">Редактировать</a>
</form> </div>
</td> </td>
@endcan
@can('delete', $grade)
<td>
<form action="{{ route('grades.destroy', $grade) }}" method="POST"
style="display: inline-block;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Удалить</button>
</form>
</td>
@endcan
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
@ -62,9 +73,11 @@
<p>Классы отсутствуют</p> <p>Классы отсутствуют</p>
@endif @endif
</div> </div>
<div class="card-footer"> @can('create', \App\Models\Grade::class)
<a href="{{ route('grades.create') }}" class="btn btn-success">Добавить</a> <div class="card-footer">
</div> <a href="{{ route('grades.create') }}" class="btn btn-success">Добавить</a>
</div>
@endcan
<div class="card-footer">{{ $grades->links() }}</div> <div class="card-footer">{{ $grades->links() }}</div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,56 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
* { font-family: DejaVu Sans !important; }
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
<title>Списки студентов</title>
</head>
<body>
<h3>Список отличников</h3>
<table>
<thead>
<tr>
<th>ФИО</th>
</tr>
</thead>
<tbody>
@foreach($excellentStudents as $student)
<tr>
<td>{{ $student->fio }}</td>
</tr>
@endforeach
</tbody>
</table>
<h3>Список хорошистов</h3>
<table>
<thead>
<tr>
<th>ФИО</th>
</tr>
</thead>
<tbody>
@foreach($goodStudents as $student)
<tr>
<td>{{ $student->fio }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@ -10,9 +10,11 @@
<h5><strong>Название: </strong>{{ $grade->name }}</h5> <h5><strong>Название: </strong>{{ $grade->name }}</h5>
</div> </div>
</div> </div>
<div class="card-footer"> @can('update', $grade)
<a href="{{ route('grades.edit', $grade) }}" class="btn btn-primary">Редактировать</a> <div class="card-footer">
</div> <a href="{{ route('grades.edit', $grade) }}" class="btn btn-primary">Редактировать</a>
</div>
@endcan
</div> </div>
<div class="card mt-4"> <div class="card mt-4">
<div class="card-header"> <div class="card-header">
@ -33,18 +35,22 @@
{{ $subject->name }} {{ $subject->name }}
</div> </div>
</td> </td>
<td> @can('journal', \App\Models\Grade::class)
<div> <td>
<a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a> <div>
</div> <a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a>
</td> </div>
<td> </td>
<form action="{{ route('grades.subjects.destroy', [$grade, $subject]) }}" method="POST" style="display: inline-block;"> @endcan
@csrf @can('delete', $grade)
@method('DELETE') <td>
<button type="submit" class="btn btn-danger">Удалить</button> <form action="{{ route('grades.subjects.destroy', [$grade, $subject]) }}" method="POST" style="display: inline-block;">
</form> @csrf
</td> @method('DELETE')
<button type="submit" class="btn btn-danger">Удалить</button>
</form>
</td>
@endcan
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
@ -53,9 +59,11 @@
<p>У класса отсутствуют предметы</p> <p>У класса отсутствуют предметы</p>
@endif @endif
</div> </div>
<div class="card-footer"> @can('create', \App\Models\Grade::class)
<a href="{{ route('grades.subjects.create', $grade) }}" class="btn btn-success">Добавить</a> <div class="card-footer">
</div> <a href="{{ route('grades.subjects.create', $grade) }}" class="btn btn-success">Добавить</a>
</div>
@endcan
</div> </div>
</div> </div>
</div> </div>

View File

@ -5,49 +5,49 @@
<div class="flex"> <div class="flex">
<!-- Logo --> <!-- Logo -->
<div class="shrink-0 flex items-center"> <div class="shrink-0 flex items-center">
<a href="{{ route('grades.index') }}"> <x-application-logo class="block h-9 w-auto fill-current text-gray-800" />
<x-application-logo class="block h-9 w-auto fill-current text-gray-800" />
</a>
</div> </div>
<!-- Navigation Links --> <!-- Navigation Links -->
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class) @can('viewAny', \App\Models\Grade::class)
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
<x-nav-link :href="route('grades.index')" :active="request()->routeIs('grades.index')"> <x-nav-link :href="route('grades.index')" :active="request()->routeIs('grades.index')">
{{ __('Классы') }} {{ __('Классы') }}
</x-nav-link> </x-nav-link>
</div> </div>
@endif @endcan
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> @can('viewAny', \App\Models\Subject::class)
<x-nav-link :href="route('subjects.index')" :active="request()->routeIs('subjects.index')"> <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
{{ __('Предметы') }} <x-nav-link :href="route('subjects.index')" :active="request()->routeIs('subjects.index')">
</x-nav-link> {{ __('Предметы') }}
</div> </x-nav-link>
</div>
@endcan
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class) @can('viewAny', \App\Models\Student::class)
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
<x-nav-link :href="route('students.index')" :active="request()->routeIs('students.index')"> <x-nav-link :href="route('students.index')" :active="request()->routeIs('students.index')">
{{ __('Студенты') }} {{ __('Ученики') }}
</x-nav-link> </x-nav-link>
</div> </div>
@endif @endcan
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Teacher::class) @can('viewAny', \App\Models\Teacher::class)
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
<x-nav-link :href="route('teachers.index')" :active="request()->routeIs('teachers.index')"> <x-nav-link :href="route('teachers.index')" :active="request()->routeIs('teachers.index')">
{{ __('Учителя') }} {{ __('Учителя') }}
</x-nav-link> </x-nav-link>
</div> </div>
@endif @endcan
@if(\Illuminate\Support\Facades\Auth::user()->userable_type == \App\Models\Student::class) @can('debts', \App\Models\Student::class)
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"> <div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
<x-nav-link :href="route('student-debts')" :active="request()->routeIs('student-debts')"> <x-nav-link :href="route('student-debts')" :active="request()->routeIs('student-debts')">
{{ __('Задолженности') }} {{ __('Задолженности') }}
</x-nav-link> </x-nav-link>
</div> </div>
@endif @endcan
</div> </div>
<!-- Settings Dropdown --> <!-- Settings Dropdown -->
@ -99,9 +99,35 @@
<!-- Responsive Navigation Menu --> <!-- Responsive Navigation Menu -->
<div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden"> <div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
<div class="pt-2 pb-3 space-y-1"> <div class="pt-2 pb-3 space-y-1">
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')"> @can('viewAny', \App\Models\Grade::class)
{{ __('Dashboard') }} <x-responsive-nav-link :href="route('grades.index')" :active="request()->routeIs('grades.index')">
</x-responsive-nav-link> {{ __('Классы') }}
</x-responsive-nav-link>
@endcan
@can('viewAny', \App\Models\Subject::class)
<x-responsive-nav-link :href="route('subjects.index')" :active="request()->routeIs('subjects.index')">
{{ __('Предметы') }}
</x-responsive-nav-link>
@endcan
@can('viewAny', \App\Models\Student::class)
<x-responsive-nav-link :href="route('students.index')" :active="request()->routeIs('students.index')">
{{ __('Ученики') }}
</x-responsive-nav-link>
@endcan
@can('viewAny', \App\Models\Teacher::class)
<x-responsive-nav-link :href="route('teachers.index')" :active="request()->routeIs('teachers.index')">
{{ __('Учителя') }}
</x-responsive-nav-link>
@endcan
@can('debts', \App\Models\Student::class)
<x-responsive-nav-link :href="route('student-debts')" :active="request()->routeIs('student-debts')">
{{ __('Задолженности') }}
</x-responsive-nav-link>
@endcan
</div> </div>
<!-- Responsive Settings Options --> <!-- Responsive Settings Options -->

View File

@ -24,6 +24,7 @@
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<th>ФИО</th> <th>ФИО</th>
<th>Класс</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</thead> </thead>
<tbody> <tbody>
@ -31,21 +32,34 @@
<tr> <tr>
<td class="table-text"> <td class="table-text">
<div> <div>
<a href="{{ route('students.show', $student) }}" class="btn btn-block col-8">{{ $student->fio }}</a> @can('view', $student)
<a href="{{ route('students.show', $student) }}" class="btn btn-block col-8">{{ $student->fio }}</a>
@else
{{ $student->fio }}
@endcan
</div> </div>
</td> </td>
<td> <td class="table-text">
<div> <div>
<a href="{{ route('students.edit', $student) }}" class="btn btn-warning">Редактировать</a> {{ $student->grade->name }}
</div> </div>
</td> </td>
<td> @can('update', $student)
<form action="{{ route('students.destroy', $student) }}" method="POST" style="display: inline-block;"> <td>
@csrf <div>
@method('DELETE') <a href="{{ route('students.edit', $student) }}" class="btn btn-warning">Редактировать</a>
<button type="submit" class="btn btn-danger">Удалить</button> </div>
</form> </td>
</td> @endcan
@can('delete', $student)
<td>
<form action="{{ route('students.destroy', $student) }}" method="POST" style="display: inline-block;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Удалить</button>
</form>
</td>
@endcan
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
@ -54,9 +68,11 @@
<p>Ученики остутствуют</p> <p>Ученики остутствуют</p>
@endif @endif
</div> </div>
<div class="card-footer"> @can('create', \App\Models\Student::class)
<a href="{{ route('students.create') }}" class="btn btn-success">Добавить</a> <div class="card-footer">
</div> <a href="{{ route('students.create') }}" class="btn btn-success">Добавить</a>
</div>
@endcan
<div class="card-footer">{{ $students->links() }}</div> <div class="card-footer">{{ $students->links() }}</div>
</div> </div>
</div> </div>

View File

@ -34,11 +34,13 @@
{{ $subject->name }} {{ $subject->name }}
</div> </div>
</td> </td>
@can('scores', $subject)
<td> <td>
<div> <div>
<a href="{{ route('student-scores', $subject) }}" class="btn btn-success">Оценки</a> <a href="{{ route('student-scores', $subject) }}" class="btn btn-success">Оценки</a>
</div> </div>
</td> </td>
@endcan
@can('update', $subject) @can('update', $subject)
<td> <td>
<div> <div>

View File

@ -31,14 +31,20 @@
<tr> <tr>
<td class="table-text"> <td class="table-text">
<div> <div>
{{ $teacher->fio }} @can('view', $teacher)
</div> <a href="{{ route('teachers.show', $teacher) }}" class="btn btn-block">{{ $teacher->fio }}</a>
</td> @else
<td> {{ $teacher->fio }}
<div> @endcan
<a href="{{ route('teachers.subjects.index', $teacher) }}" class="btn btn-warning">Предметы</a>
</div> </div>
</td> </td>
@can('teacherSubjects', $teacher)
<td>
<div>
<a href="{{ route('teachers.subjects.index', $teacher) }}" class="btn btn-warning">Предметы</a>
</div>
</td>
@endcan
@can('update', $teacher) @can('update', $teacher)
<td> <td>
<div> <div>
@ -63,7 +69,7 @@
<p>Учителя отсутствуют</p> <p>Учителя отсутствуют</p>
@endif @endif
</div> </div>
@can('create', Teacher::class) @can('create', \App\Models\Teacher::class)
<div class="card-footer"> <div class="card-footer">
<a href="{{ route('teachers.create') }}" class="btn btn-success">Добавить</a> <a href="{{ route('teachers.create') }}" class="btn btn-success">Добавить</a>
</div> </div>

View File

@ -46,6 +46,7 @@ Route::middleware('auth')->group(function () {
Route::get('lessons/{lesson}/scores', [ScoreController::class, 'show'])->name('lessons.scores.show'); Route::get('lessons/{lesson}/scores', [ScoreController::class, 'show'])->name('lessons.scores.show');
Route::put('lessons/{lesson}/scores', [ScoreController::class, 'update'])->name('lessons.scores.update'); Route::put('lessons/{lesson}/scores', [ScoreController::class, 'update'])->name('lessons.scores.update');
Route::get('grades/{grade}/subjects/{subject}/journal', [GradeSubjectController::class, 'journal'])->name('grades.subjects.journal'); Route::get('grades/{grade}/subjects/{subject}/journal', [GradeSubjectController::class, 'journal'])->name('grades.subjects.journal');
Route::get('grades/{grade}/list-students', [GradeController::class, 'listStudents'])->name('list-students');
}); });
Route::middleware([StudentAction::class])->group(function () { Route::middleware([StudentAction::class])->group(function () {