Files
PiAPS_University_Web/University.Web/resources/views/students/form.blade.php

188 lines
12 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
{{ isset($student) ? 'Редактирование студента' : 'Добавление нового студента' }}
</div>
<div class="card-body">
<form method="POST" action="{{ isset($student) ? route('students.update', $student['id']) : route('students.store') }}">
@csrf
@if(isset($student))
@method('PATCH')
@endif
<div class="row mb-3">
<label for="surname" class="col-md-4 col-form-label text-md-end">Фамилия*</label>
<div class="col-md-6">
<input id="surname" type="text" class="form-control @error('surname') is-invalid @enderror" name="surname" value="{{ old('surname', $student['surname'] ?? '') }}" required autocomplete="surname" autofocus>
@error('surname')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="name" class="col-md-4 col-form-label text-md-end">Имя*</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name', $student['name'] ?? '') }}" required autocomplete="name">
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="patronymic" class="col-md-4 col-form-label text-md-end">Отчество</label>
<div class="col-md-6">
<input id="patronymic" type="text" class="form-control @error('patronymic') is-invalid @enderror" name="patronymic" value="{{ old('patronymic', $student['patronymic'] ?? '') }}" autocomplete="patronymic">
@error('patronymic')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">Email*</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email', $student['email'] ?? '') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="telephone" class="col-md-4 col-form-label text-md-end">Телефон*</label>
<div class="col-md-6">
<input id="telephone"
type="text"
class="form-control @error('telephone') is-invalid @enderror"
name="telephone"
value="{{ old('telephone', $student['telephone'] ?? '') }}"
required
pattern="^[0-9\+\-\(\)\s]+$"
inputmode="tel"
title="Введите только цифры, пробелы, +, -, ( )">
@error('telephone')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="password" class="col-md-4 col-form-label text-md-end">{{ isset($student) ? 'Новый пароль' : 'Пароль*' }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" {{ isset($student) ? '' : 'required' }} autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="gender" class="col-md-4 col-form-label text-md-end">Пол*</label>
<div class="col-md-6">
<select id="gender" class="form-control @error('gender') is-invalid @enderror" name="gender" required>
<option value="" disabled {{ old('gender', $student['gender'] ?? '') == '' ? 'selected' : '' }} hidden>Выберите пол</option>
<option value="М" {{ (old('gender', $student['gender'] ?? '') == 'М' ? 'selected' : '') }}>Мужской</option>
<option value="Ж" {{ (old('gender', $student['gender'] ?? '') == 'Ж' ? 'selected' : '') }}>Женский</option>
</select>
@error('gender')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="birth_date" class="col-md-4 col-form-label text-md-end">Дата рождения*</label>
<div class="col-md-6">
<input id="birth_date" type="date" class="form-control @error('birth_date') is-invalid @enderror" name="birth_date" value="{{ old('birth_date', $student['birth_date'] ?? '') }}" required>
@error('birth_date')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="citizenship" class="col-md-4 col-form-label text-md-end">Гражданство*</label>
<div class="col-md-6">
<input id="citizenship" type="text" class="form-control @error('citizenship') is-invalid @enderror" name="citizenship" value="{{ old('citizenship', $student['citizenship'] ?? '') }}" required>
@error('citizenship')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="group_id" class="col-md-4 col-form-label text-md-end">Группа</label>
<div class="col-md-6">
<select id="group_id" class="form-control @error('group_id') is-invalid @enderror" name="group_id">
<option value="" disabled {{ empty($student['student_profile']['group_id']) ? 'selected' : '' }} hidden>Не выбрана</option>
@foreach($groups as $group)
<option value="{{ $group['id'] }}"
{{ (isset($student['student_profile']['group_id']) && $student['student_profile']['group_id'] == $group['id']) ? 'selected' : '' }}>
{{ $group['name'] }}
</option>
@endforeach
</select>
@error('group_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="matriculation_number" class="col-md-4 col-form-label text-md-end">Номер зачетной книжки</label>
<div class="col-md-6">
<input id="matriculation_number" type="text" class="form-control @error('matriculation_number') is-invalid @enderror" name="matriculation_number" value="{{ $student['student_profile']['matriculation_number'] ?? old('matriculation_number') }}">
@error('matriculation_number')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ isset($student) ? 'Обновить' : 'Создать' }}
</button>
<a href="{{ route('students.index') }}" class="btn btn-secondary">Отмена</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection