Compare commits

..

No commits in common. "604d5a902cae39a2381f9f52ff931c450a4a0408" and "88c692bfe19ce8e063e74a7b6d7596ab2eec2fac" have entirely different histories.

23 changed files with 153 additions and 199 deletions

View File

@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreDocumentsOnlineRequest;
use App\Http\Requests\UpdateDocumentsOnlineRequest;
use App\Models\DocumentsOnline;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class DocumentsOnlineController extends Controller
{
public function index()
{
$documentsOnline = DocumentsOnline::all();
return view('documents-online.index', compact('documentsOnline'));
}
public function create(DocumentsOnline $documentOnline): View
{
if (Auth::guest()) {
abort(403);
}
$parent = $documentOnline;
return view('documents-online', compact('parent'));
}
public function store(StoreDocumentsOnlineRequest $request)
{
}
/**
* Display the specified resource.
*/
public function show(DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateDocumentsOnlineRequest $request, DocumentsOnline $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(DocumentsOnline $doceumentsOnline)
{
//
}
}

View File

@ -1,65 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreOnlineDocumentsRequest;
use App\Http\Requests\UpdateOnlineDocumentsRequest;
use App\Models\OnlineDocuments;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class OnlineDocumentsController extends Controller
{
public function index()
{
$onlineDocuments = OnlineDocuments::all();
return view('online-documents.index', compact('onlineDocuments'));
}
public function create(OnlineDocuments $documentOnline): View
{
if (Auth::guest()) {
abort(403);
}
$parent = $documentOnline;
return view('online-documents', compact('parent'));
}
public function store(StoreOnlineDocumentsRequest $request)
{
}
/**
* Display the specified resource.
*/
public function show(OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateOnlineDocumentsRequest $request, OnlineDocuments $doceumentsOnline)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(OnlineDocuments $doceumentsOnline)
{
//
}
}

View File

@ -4,25 +4,16 @@ namespace App\Http\Controllers;
use App\Http\Requests\UpdateUserRequest;
use App\Models\User;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class UserController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$users = User::all();
return view('users.index', compact('users'));
}
@ -32,9 +23,7 @@ class UserController extends Controller
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
$validated = $request->validated();
$user = new User();
@ -48,9 +37,6 @@ class UserController extends Controller
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
@ -59,9 +45,6 @@ class UserController extends Controller
public function edit(User $user): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
@ -70,19 +53,13 @@ class UserController extends Controller
public function update(UpdateUserRequest $request, User $user): RedirectResponse
{
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$validated = $request->validated();
$user->name = $validated['name'];
$user->password = Hash::make($validated['password']);
$user->email = $validated['email'];
$user->remember_token = Str::random(60);
$user->fill($validated);
$user->save();
return redirect()->route('users.index');
@ -90,12 +67,6 @@ class UserController extends Controller
public function destroy(User $user): RedirectResponse
{
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
$user->delete();
return redirect()->route('users.index');

View File

@ -4,7 +4,7 @@ namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreOnlineDocumentsRequest extends FormRequest
class StoreDocumentsOnlineRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.

View File

@ -25,7 +25,7 @@ class StoreUserRequest extends FormRequest
{
return [
'name' => 'required|unique:users,name|max:255',
'email' => 'email',
'email' => 'email:rfc,dns',
'password' => 'required'
];
}

View File

@ -4,7 +4,7 @@ namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateOnlineDocumentsRequest extends FormRequest
class UpdateDocumentsOnlineRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.

View File

@ -24,8 +24,8 @@ class UpdateUserRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:255',
'email' => 'email',
'name' => 'required|unique:users,name|max:255',
'email' => 'email:rfc,dns',
'password' => 'required'
];
}

View File

@ -5,15 +5,14 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class OnlineDocuments extends Model
class DocumentsOnline extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'url',
'parent',
'children'
'description',
'url'
];
}

View File

@ -31,6 +31,7 @@ class User extends Authenticatable
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

View File

@ -2,11 +2,11 @@
namespace App\Policies;
use App\Models\OnlineDocuments;
use App\Models\DocumentsOnline;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class OnlineDocumentsPolicy
class DocumentsOnlinePolicy
{
/**
* Determine whether the user can view any models.
@ -19,7 +19,7 @@ class OnlineDocumentsPolicy
/**
* Determine whether the user can view the model.
*/
public function view(User $user, OnlineDocuments $doceumentsOnline): bool
public function view(User $user, DocumentsOnline $doceumentsOnline): bool
{
//
}
@ -35,7 +35,7 @@ class OnlineDocumentsPolicy
/**
* Determine whether the user can update the model.
*/
public function update(User $user, OnlineDocuments $doceumentsOnline): bool
public function update(User $user, DocumentsOnline $doceumentsOnline): bool
{
//
}
@ -43,7 +43,7 @@ class OnlineDocumentsPolicy
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, OnlineDocuments $doceumentsOnline): bool
public function delete(User $user, DocumentsOnline $doceumentsOnline): bool
{
//
}
@ -51,7 +51,7 @@ class OnlineDocumentsPolicy
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, OnlineDocuments $doceumentsOnline): bool
public function restore(User $user, DocumentsOnline $doceumentsOnline): bool
{
//
}
@ -59,7 +59,7 @@ class OnlineDocumentsPolicy
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, OnlineDocuments $doceumentsOnline): bool
public function forceDelete(User $user, DocumentsOnline $doceumentsOnline): bool
{
//
}

View File

@ -5,7 +5,7 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OnlineDocuments>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DocumentsOnline>
*/
class DocumentsOnlineFactory extends Factory
{

View File

@ -11,7 +11,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('online_documents', function (Blueprint $table) {
Schema::create('documents_online', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('url');
@ -26,6 +26,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('online_documents');
Schema::dropIfExists('documents_online');
}
};

View File

@ -20,8 +20,8 @@ class DatabaseSeeder extends Seeder
'email' => 'test@example.com',
'password' => 123456
]);
$this->call([
OnlineDocumentsSeeder::class
]);
// $this->call([
// DocumentsOnlineSeeder::class
// ]);
}
}

View File

@ -7,14 +7,14 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class OnlineDocumentsSeeder extends Seeder
class DocumentsOnlineSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('online_documents')->insert([
DB::table('documents_online')->insert([
[
'name' => 'Подать документы онлайн',
'url' => '',

View File

@ -0,0 +1,8 @@
@extends('layouts.admin-layout')
@section('content')
@foreach($documentsOnline as $documentOnline)
{{ $documentOnline->name }}
{{ $documentOnline->url }}
{{ $documentOnline->description }}
@endforeach
@endsection

View File

@ -6,8 +6,7 @@
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="csrf-param" content="_token"/>
<title>Панель администратора</title>
@vite(['resources/js/app.js'])
<title>{{ __('layout.title') }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.su/docs/5.3/assets/css/docs.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
@ -17,12 +16,12 @@
<header
class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom">
<ul class="nav col-9 col-md-auto mb-2 justify-content-start mb-md-0">
<li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li>
<li><a href="#" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li>
</ul>
<div class="col-md-3 text-center">
<a href="{{ route('home') }}" class="nav-link px-2 link-secondary">Сайт abitur.mkgtu.ru</a>
<a href="#" class="nav-link px-2 link-secondary">Сайт abitur.mkgtu.ru</a>
</div>
<div class="col-md-3 text-end">
@ -46,11 +45,10 @@
</div>
</header>
<div class="row align-items-start">
<aside class="list-group col-2">
<ul>
<aside>
<ul class="list-group col-2">
<li class="list-group-item">
<a href="{{ route('online-documents.index') }}">Подать Документы онлайн</a>
<a href="{{ route('documents-online.index') }}">Подать Документы онлайн</a>
</li>
<li class="list-group-item"><a href="">Абитуриенту</a></li>
<li class="list-group-item"><a href="">Экран Приема</a></li>
@ -59,15 +57,9 @@
<li class="list-group-item"><a href="">Стоимость обучения</a></li>
<li class="list-group-item"><a href="">Олимпиады для школьников</a></li>
<li class="list-group-item"><a href="">Подготовительные курсы</a></li>
@if(Auth::getUser()->name === 'admin')
<li class="list-group-item"></li>
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
@endif
</ul>
</aside>
<div class="col-10">@yield('content')</div>
</div>
@yield('content')
</div>
</body>
</html>

View File

@ -12,7 +12,7 @@
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
<!-- Scripts -->
@vite(['resources/css/app.css', 'resources/js/app.js'])
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head>
<body class="font-sans antialiased">
<div class="min-h-screen bg-gray-100 dark:bg-gray-900">

View File

@ -12,7 +12,7 @@
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
<!-- Scripts -->
@vite(['resources/css/app.css', 'resources/js/app.js'])
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head>
<body class="font-sans text-gray-900 antialiased" >
<div class="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 bg-gray-100 dark:bg-gray-900" style="background-color:#006147">

View File

@ -1,11 +0,0 @@
@extends('layouts.admin-layout')
@section('content')
@foreach($onlineDocuments as $onlineDocument)
<div>
{{ $onlineDocument->name }}
{{ $onlineDocument->url }}
{{ $onlineDocument->parent }}
{{ $onlineDocument->children }}
</div>
@endforeach
@endsection

View File

@ -1,17 +1,15 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="">
<h1 class=""> Создать администратора</h1>
<div class="grid col-span-full">
<h1 class="max-w-2xl mb-4 text-4xl leading-none tracking-tight md:text-5xl xl:text-6xl dark:text-white"> создать
пользователя</h1>
{{ Form::open(['url' => route('users.store'), 'method' => 'POST', 'class' => '']) }}
<div class="col-4">
{{ Form::open(['url' => route('users.store'), 'method' => 'POST', 'class' => 'w-50']) }}
<div class="flex flex-col">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }}
{{ Form::text('name', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -23,7 +21,7 @@
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', '', ['class' => 'form-control']) }}
{{ Form::text('email', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -35,7 +33,7 @@
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
{{ Form::text('password', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -44,10 +42,9 @@
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
{{ Form::submit('создать', ['class' => 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

@ -1,18 +1,15 @@
@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 class="grid col-span-full">
<h1 class="max-w-2xl mb-4 text-4xl leading-none tracking-tight md:text-5xl xl:text-6xl dark:text-white"> Изменить
пользователя</h1>
{{ Form::open(['url' => route('users.update', $user), 'method' => 'PATCH', 'class' => 'w-50']) }}
<div class="flex flex-col">
<div>
{{ Form::label('name', 'Логин') }}
</div>
<div class="mt-2">
{{ Form::text('name', $user->name, ['class' => 'form-control']) }}
{{ Form::text('name', $user->name, ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -24,7 +21,7 @@
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', $user->email, ['class' => 'form-control']) }}
{{ Form::text('email', $user->email, ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -36,7 +33,7 @@
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control']) }}
{{ Form::text('password', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
</div>
<div>
@if ($errors->any())
@ -45,10 +42,9 @@
</div>
<div class="mt-4">
{{ Form::submit('изменить', ['class' => 'btn btn-primary']) }}
{{ Form::submit('изменить', ['class' => 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

@ -1,29 +1,30 @@
@extends('layouts.admin-layout')
@section('content')
<div class="container">
<h2>список Администраторов</h2>
<br>
<a href="{{ route('users.create') }}" class="btn btn-primary">Создать администратора</a>
<h2>список пользователей</h2>
<br>
<br>
<table class="table">
<a href="{{ route('users.create') }}"> создать пользователя</a>
<br>
<br>
<table class="mt-4">
<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>
<th>id</th>
<td>name</td>
<td>email</td>
<td>действия</td>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->id }}</td>
<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">
<td><a href="{{ route("users.edit", $user) }}">редактировать</a></td>
<td><a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('users.destroy', $user) }}">
удалить
</a>
</td>

View File

@ -1,6 +1,6 @@
<?php
use App\Http\Controllers\OnlineDocumentsController;
use App\Http\Controllers\DocumentsOnlineController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UploadFileController;
use App\Http\Controllers\UserController;
@ -23,7 +23,7 @@ Route::get('/', function () {
Route::resources([
'/users' => UserController::class,
'/online-documents' => OnlineDocumentsController::class
'/documents-online' => DocumentsOnlineController::class
]);
Route::get('/course', function () {