Compare commits

...

4 Commits

Author SHA1 Message Date
aslan 604d5a902c any fix layouts
Tests & Lint & Deploy to Railway / build (20.x, 8.2) (push) Successful in 2m0s Details
Tests & Lint & Deploy to Railway / deploy (8.1) (push) Failing after 1m21s Details
2024-01-19 19:17:21 +03:00
aslan 9a8db88d6d any fix resource User 2024-01-19 19:17:08 +03:00
aslan 00d64e149a add resource Documents Online 2024-01-19 19:15:51 +03:00
aslan ff2deace3e add resource Documents Online 2024-01-19 19:15:45 +03:00
23 changed files with 200 additions and 154 deletions

View File

@ -1,65 +0,0 @@
<?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

@ -0,0 +1,65 @@
<?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,16 +4,25 @@ 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'));
}
@ -23,7 +32,9 @@ class UserController extends Controller
if (Auth::guest()) {
abort(403, 'Вы не авторизованы!');
}
if (!Auth::user('admin')) {
abort(403, 'У вас нет прав доступа');
}
$validated = $request->validated();
$user = new User();
@ -37,6 +48,9 @@ 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, 'Вы не авторизованы!');
}
@ -45,6 +59,9 @@ 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, 'Вы не авторизованы!');
}
@ -53,13 +70,19 @@ 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->fill($validated);
$user->name = $validated['name'];
$user->password = Hash::make($validated['password']);
$user->email = $validated['email'];
$user->remember_token = Str::random(60);
$user->save();
return redirect()->route('users.index');
@ -67,6 +90,12 @@ 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 StoreDocumentsOnlineRequest extends FormRequest
class StoreOnlineDocumentsRequest 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:rfc,dns',
'email' => 'email',
'password' => 'required'
];
}

View File

@ -4,7 +4,7 @@ namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDocumentsOnlineRequest extends FormRequest
class UpdateOnlineDocumentsRequest 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|unique:users,name|max:255',
'email' => 'email:rfc,dns',
'name' => 'required|max:255',
'email' => 'email',
'password' => 'required'
];
}

View File

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

View File

@ -31,7 +31,6 @@ 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\DocumentsOnline;
use App\Models\OnlineDocuments;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class DocumentsOnlinePolicy
class OnlineDocumentsPolicy
{
/**
* Determine whether the user can view any models.
@ -19,7 +19,7 @@ class DocumentsOnlinePolicy
/**
* Determine whether the user can view the model.
*/
public function view(User $user, DocumentsOnline $doceumentsOnline): bool
public function view(User $user, OnlineDocuments $doceumentsOnline): bool
{
//
}
@ -35,7 +35,7 @@ class DocumentsOnlinePolicy
/**
* Determine whether the user can update the model.
*/
public function update(User $user, DocumentsOnline $doceumentsOnline): bool
public function update(User $user, OnlineDocuments $doceumentsOnline): bool
{
//
}
@ -43,7 +43,7 @@ class DocumentsOnlinePolicy
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, DocumentsOnline $doceumentsOnline): bool
public function delete(User $user, OnlineDocuments $doceumentsOnline): bool
{
//
}
@ -51,7 +51,7 @@ class DocumentsOnlinePolicy
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, DocumentsOnline $doceumentsOnline): bool
public function restore(User $user, OnlineDocuments $doceumentsOnline): bool
{
//
}
@ -59,7 +59,7 @@ class DocumentsOnlinePolicy
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, DocumentsOnline $doceumentsOnline): bool
public function forceDelete(User $user, OnlineDocuments $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\DocumentsOnline>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OnlineDocuments>
*/
class DocumentsOnlineFactory extends Factory
{

View File

@ -11,7 +11,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('documents_online', function (Blueprint $table) {
Schema::create('online_documents', 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('documents_online');
Schema::dropIfExists('online_documents');
}
};

View File

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

View File

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

View File

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

View File

@ -6,7 +6,8 @@
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="csrf-param" content="_token"/>
<title>{{ __('layout.title') }}</title>
<title>Панель администратора</title>
@vite(['resources/js/app.js'])
<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>
@ -16,12 +17,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="#" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li>
<li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li>
</ul>
<div class="col-md-3 text-center">
<a href="#" class="nav-link px-2 link-secondary">Сайт abitur.mkgtu.ru</a>
<a href="{{ route('home') }}" class="nav-link px-2 link-secondary">Сайт abitur.mkgtu.ru</a>
</div>
<div class="col-md-3 text-end">
@ -45,21 +46,28 @@
</div>
</header>
<aside>
<ul class="list-group col-2">
<li class="list-group-item">
<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>
<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>
<li class="list-group-item"><a href="">Олимпиады для школьников</a></li>
<li class="list-group-item"><a href="">Подготовительные курсы</a></li>
</ul>
</aside>
@yield('content')
<div class="row align-items-start">
<aside class="list-group col-2">
<ul>
<li class="list-group-item">
<a href="{{ route('online-documents.index') }}">Подать Документы онлайн</a>
</li>
<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>
<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>
<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>
</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/sass/app.scss', 'resources/js/app.js'])
@vite(['resources/css/app.css', '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/sass/app.scss', 'resources/js/app.js'])
@vite(['resources/css/app.css', '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

@ -0,0 +1,11 @@
@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,15 +1,17 @@
@auth()
<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>
@extends('layouts.admin-layout')
@section('content')
{{ Form::open(['url' => route('users.store'), 'method' => 'POST', 'class' => 'w-50']) }}
<div class="flex flex-col">
@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 rounded border-gray-300 w-1/3']) }}
{{ Form::text('name', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -21,7 +23,7 @@
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
{{ Form::text('email', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -33,7 +35,7 @@
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -42,9 +44,10 @@
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded']) }}
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

@ -1,15 +1,18 @@
@auth()
<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>
@extends('layouts.admin-layout')
@section('content')
{{ Form::open(['url' => route('users.update', $user), 'method' => 'PATCH', 'class' => 'w-50']) }}
<div class="flex flex-col">
@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 rounded border-gray-300 w-1/3']) }}
{{ Form::text('name', $user->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -21,7 +24,7 @@
{{ Form::label('email', 'электронная почта') }}
</div>
<div class="mt-2">
{{ Form::text('email', $user->email, ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
{{ Form::text('email', $user->email, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -33,7 +36,7 @@
{{ Form::label('password', 'Пароль') }}
</div>
<div class="mt-2">
{{ Form::text('password', '', ['class' => 'form-control rounded border-gray-300 w-1/3']) }}
{{ Form::text('password', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -42,9 +45,10 @@
</div>
<div class="mt-4">
{{ Form::submit('изменить', ['class' => 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded']) }}
{{ Form::submit('изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
@endauth
@endsection

View File

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

View File

@ -1,6 +1,6 @@
<?php
use App\Http\Controllers\DocumentsOnlineController;
use App\Http\Controllers\OnlineDocumentsController;
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,
'/documents-online' => DocumentsOnlineController::class
'/online-documents' => OnlineDocumentsController::class
]);
Route::get('/course', function () {