prod #14

Merged
klllst merged 24 commits from develop into master 2024-06-25 21:58:29 +04:00
6 changed files with 32 additions and 13 deletions
Showing only changes of commit 769760f414 - Show all commits

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

@ -41,11 +41,13 @@
<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>
@can('list', \App\Models\Grade::class)
<td> <td>
<div> <div>
<a href="{{ route('list-students', $grade) }}" class="btn btn-info">Списки учеников</a> <a href="{{ route('list-students', $grade) }}" class="btn btn-info">Списки учеников</a>
</div> </div>
</td> </td>
@endcan
@can('update', $grade) @can('update', $grade)
<td> <td>
<div> <div>

View File

@ -35,11 +35,13 @@
{{ $subject->name }} {{ $subject->name }}
</div> </div>
</td> </td>
@can('journal', \App\Models\Grade::class)
<td> <td>
<div> <div>
<a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a> <a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a>
</div> </div>
</td> </td>
@endcan
@can('delete', $grade) @can('delete', $grade)
<td> <td>
<form action="{{ route('grades.subjects.destroy', [$grade, $subject]) }}" method="POST" style="display: inline-block;"> <form action="{{ route('grades.subjects.destroy', [$grade, $subject]) }}" method="POST" style="display: inline-block;">

View File

@ -69,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>