prod #14
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StudentPostRequest extends FormRequest
|
||||
{
|
||||
@ -27,7 +29,7 @@ class StudentPostRequest extends FormRequest
|
||||
'middle_name' => 'required|max:255',
|
||||
'birthday' => 'required|date',
|
||||
'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',
|
||||
];
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class TeacherPostRequest extends FormRequest
|
||||
{
|
||||
@ -26,7 +28,7 @@ class TeacherPostRequest extends FormRequest
|
||||
'last_name' => 'required|max:255',
|
||||
'middle_name' => 'required|max:255',
|
||||
'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',
|
||||
];
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace App\Policies;
|
||||
use App\Models\Admin;
|
||||
use App\Models\Grade;
|
||||
use App\Models\Student;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\User;
|
||||
|
||||
class GradePolicy
|
||||
@ -48,4 +49,14 @@ class GradePolicy
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +41,13 @@
|
||||
<a href="{{ route('grades.lessons.index', $grade) }}" class="btn btn-primary">Занятия</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('list-students', $grade) }}" class="btn btn-info">Списки учеников</a>
|
||||
</div>
|
||||
</td>
|
||||
@can('list', \App\Models\Grade::class)
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('list-students', $grade) }}" class="btn btn-info">Списки учеников</a>
|
||||
</div>
|
||||
</td>
|
||||
@endcan
|
||||
@can('update', $grade)
|
||||
<td>
|
||||
<div>
|
||||
|
@ -35,11 +35,13 @@
|
||||
{{ $subject->name }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a>
|
||||
</div>
|
||||
</td>
|
||||
@can('journal', \App\Models\Grade::class)
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a>
|
||||
</div>
|
||||
</td>
|
||||
@endcan
|
||||
@can('delete', $grade)
|
||||
<td>
|
||||
<form action="{{ route('grades.subjects.destroy', [$grade, $subject]) }}" method="POST" style="display: inline-block;">
|
||||
|
@ -69,7 +69,7 @@
|
||||
<p>Учителя отсутствуют</p>
|
||||
@endif
|
||||
</div>
|
||||
@can('create', Teacher::class)
|
||||
@can('create', \App\Models\Teacher::class)
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('teachers.create') }}" class="btn btn-success">Добавить</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user