refactoring User resource

This commit is contained in:
aslan 2024-02-14 10:20:40 +03:00
parent a5f8751f94
commit 0cdc43d547
8 changed files with 167 additions and 170 deletions

View File

@ -1,4 +1,4 @@
@extends('layouts.admin-layout')
@extends('layouts.admin_layout')
@section('content')
@auth()
<div class="row">
@ -27,6 +27,17 @@
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('description', 'Описание') }}
</div>
<div class="mt-2">
{{ Form::text('description', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('description') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('position', 'Позиция') }}
</div>
@ -39,14 +50,14 @@
@endif
</div>
<div class="mt-2">
{{ Form::label('idReceptionScreen', 'Пункт экрана приема') }}
{{ Form::label('admission_id', 'Пункт экрана приема') }}
</div>
<div class="mt-2">
{{ Form::select('idReceptionScreen', $receptionScreens, null, ['class' => 'form-select']) }}
{{ Form::select('admission_id', $admissions, null, ['class' => 'form-select']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('idReceptionScreen') }}
{{ $errors->first('admission_id') }}
@endif
</div>
<div class="mt-4">
@ -54,26 +65,6 @@
</div>
{{Form::close()}}
</div>
{{-- @if($idReceptionScreen !== null)--}}
{{-- <div class="col">--}}
{{-- <h2>Файлы пункта Экрана Приема: {{ $receptionScreens[$idReceptionScreen] }}</h2>--}}
{{-- <table class="table">--}}
{{-- <thead class="border-b-2 border-solid border-black text-left" style="text-align: left">--}}
{{-- <tr>--}}
{{-- <th scope="col">Позиция</th>--}}
{{-- <th scope="col">Название</th>--}}
{{-- </tr>--}}
{{-- </thead>--}}
{{-- <tbody>--}}
{{-- @foreach($files as $file)--}}
{{-- <tr>--}}
{{-- <th scope="row">{{ $file->position }}</th>--}}
{{-- <th scope="row">{{ $file->name }}</th>--}}
{{-- @endforeach--}}
{{-- </tbody>--}}
{{-- </table>--}}
{{-- </div>--}}
{{-- @endif--}}
</div>
@endauth
@endsection

View File

@ -0,0 +1,54 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
@can('create', Auth::user())
<div class="">
<h1 class=""> Создать администратора</h1>
{{ Form::open(['url' => route('users.store'), 'method' => 'POST', 'class' => '']) }}
<div class="col-4">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div>
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('email') }}
@endif
</div>
<div>
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('password') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endcan
@endauth
@endsection

View File

@ -0,0 +1,55 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
@can('update', Auth::user())
<div>
<h1 class=""> Изменить Администратора</h1>
<br>
<br>
{{ Form::open(['url' => route('users.update', $user), 'method' => 'PATCH', 'class' => '']) }}
<div class="col-4">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', $user->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div>
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', $user->email, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('email') }}
@endif
</div>
<div>
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('password') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endcan
@endauth
@endsection

View File

@ -0,0 +1,41 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
@can('viewAny', Auth::user())
<div class="container">
<h2>список Администраторов</h2>
<br>
<a href="{{ route('users.create') }}" class="btn btn-primary">Создать администратора</a>
<br>
<br>
<table class="table">
<thead class="border-b-2 border-solid border-black text-left" style="text-align: left">
<tr>
<th scope="col">id</th>
<th scope="col">name</th>
<th scope="col">email</th>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td><a href="{{ route("users.edit", $user) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('users.destroy', $user) }}" class="btn btn-danger">
удалить
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endcan
@endauth
@endsection

View File

@ -45,10 +45,10 @@
<ul>
<li class="list-group-item"><a href="{{ route('documents.index') }}">Документы</a></li>
<li class="list-group-item"><a href="{{ route('admissions.index') }}">Экран Приема</a></li>
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
@can('viewAny', Auth::user())
<li class="list-group-item"></li>
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
@endif
@endcan
<li class="list-group-item"></li>
<li class="list-group-item">Справочники</li>
<li class="list-group-item"><a href="{{ route('educational_institutions.index') }}">Учебные

View File

@ -1,53 +0,0 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="">
<h1 class=""> Создать администратора</h1>
{{ Form::open(['url' => route('users.store'), 'method' => 'POST', 'class' => '']) }}
<div class="col-4">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div>
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('email') }}
@endif
</div>
<div>
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('password') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

@ -1,54 +0,0 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div>
<h1 class=""> Изменить Администратора</h1>
<br>
<br>
{{ Form::open(['url' => route('users.update', $user), 'method' => 'PATCH', 'class' => '']) }}
<div class="col-4">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', $user->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div>
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', $user->email, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('email') }}
@endif
</div>
<div>
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('password') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

@ -1,37 +0,0 @@
@extends('layouts.admin-layout')
@section('content')
<div class="container">
<h2>список Администраторов</h2>
<br>
<a href="{{ route('users.create') }}" class="btn btn-primary">Создать администратора</a>
<br>
<br>
<table class="table">
<thead class="border-b-2 border-solid border-black text-left" style="text-align: left">
<tr>
<th scope="col">id</th>
<th scope="col">name</th>
<th scope="col">email</th>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td><a href="{{ route("users.edit", $user) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('users.destroy', $user) }}" class="btn btn-danger">
удалить
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endsection