Compare commits

..

No commits in common. "88919c251dc7365c7fb7f29addb669ab859fff19" and "e15ff69e01a1b51e7b0d3f28fd1550738d56708b" have entirely different histories.

170 changed files with 1639 additions and 4218 deletions

View File

@ -4,9 +4,6 @@ APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
ADMIN_NAME=admin
ADMIN_EMAIL=test@example.com
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

View File

@ -14,23 +14,16 @@ jobs:
strategy:
matrix:
php-version: [ '8.3' ]
php-versions: [ '8.3' ]
node-version: ['20.x']
composer-version: ['2.6.6']
steps:
- uses: actions/checkout@v4
- name: Set up PHP ${{ matrix.php-version }} with extensions and tools
- name: Set up PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
tools: composer:${{ matrix.composer-version }}
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
env:
debug: true
php-version: ${{ matrix.php-versions }}
- name: PHP Security Checker
uses: StephaneBour/actions-php-security-checker@1.1
@ -44,14 +37,22 @@ jobs:
run: |
sudo curl -o ~/.composer/keys.tags.pub -sL https://composer.github.io/releases.pub
sudo curl -o ~/.composer/keys.dev.pub -sL https://composer.github.io/snapshots.pub
- run: echo $COMPOSER_AUTH|jq -r '.["github-oauth"]["github.com"]'|base64
- run: echo $GITHUB_TOKEN|base64
- name: Diagnose composer
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }} # only this works
run: composer diagnose -vvv
- name: Install dependencies
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }}
run: composer install
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }} # only this works
run: composer install # will work
- name: Setup sqlite3 driver
run: apt install php${{ matrix.php-versions }}-sqlite3 -y
- name: Setup project
run: make setup-test
run: make setup
- name: Check lint
run: make lint
@ -63,7 +64,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- name: deploy to test server
- name: Checkout
uses: appleboy/ssh-action@v1.0.3
with:
@ -75,5 +76,4 @@ jobs:
cd /var/www/test-testabit/
git stash
git pull --rebase
git stash clear
make setup-test

View File

@ -16,11 +16,11 @@ setup:
make ide-helper
setup-test:
composer install
cp -n .env.example .env
composer install --no-plugins --no-scripts
php artisan key:gen --ansi
rm database/database.sqlite
touch database/database.sqlite
php artisan migrate:refresh
php artisan migrate
php artisan db:seed
npm ci
npm run build

View File

@ -2,11 +2,7 @@
Сайт с Админкой для редактирования Экрана приема
```text
Сайт: http://test-testabit.mkgtu.ru
логин: test@example.com
пароль: 123456
```
Сайт:
## Requirements:
- PHP ^8.2
@ -20,7 +16,6 @@ git clone http://172.17.254.104/aslan/applicant-site.git
cd applicant-site
make setup
```
2255
## Project start local

View File

@ -1,10 +1,9 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreEducationalInstitutionRequest;
use App\Http\Requests\admin\Catalog\UpdateEducationalInstitutionRequest;
use App\Http\Requests\StoreEducationalInstitutionRequest;
use App\Http\Requests\UpdateEducationalInstitutionRequest;
use App\Models\EducationalInstitution;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
@ -15,12 +14,12 @@ class EducationalInstitutionController extends Controller
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$educationalInstitutions = EducationalInstitution::all();
return view('admin.catalog.educational_institution.index', compact('educationalInstitutions'));
return view('catalog.educational-institution.index', compact('educationalInstitutions'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
return view('admin.catalog.educational_institution.create');
return view('catalog.educational-institution.create');
}
public function store(StoreEducationalInstitutionRequest $request)
@ -30,21 +29,20 @@ class EducationalInstitutionController extends Controller
$educationalInstitution = new EducationalInstitution();
$educationalInstitution->name = $validated['name'];
$educationalInstitution->description = $validated['description'];
$educationalInstitution->slug = $validated['slug'];
$educationalInstitution->position = $validated['position'];
$educationalInstitution->save();
return redirect()->route('educational_institutions.index');
return redirect()->route('educational-institutions.index');
}
public function show(EducationalInstitution $educationalInstitution)
{
return view('admin.catalog.educational_institution.show', compact('educationalInstitution'));
return view('catalog.educational-institution.show', compact('educationalInstitution'));
}
public function edit(EducationalInstitution $educationalInstitution)
{
return view('admin.catalog.educational_institution.edit', compact('educationalInstitution'));
return view('catalog.educational-institution.edit', compact('educationalInstitution'));
}
public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution)
@ -54,10 +52,9 @@ class EducationalInstitutionController extends Controller
$educationalInstitution->name = $validated['name'];
$educationalInstitution->description = $validated['description'];
$educationalInstitution->position = $validated['position'];
$educationalInstitution->slug = $validated['slug'];
$educationalInstitution->save();
return redirect()->route('educational_institutions.index');
return redirect()->route('educational-institutions.index');
}
public function destroy(EducationalInstitution $educationalInstitution)
@ -67,6 +64,6 @@ class EducationalInstitutionController extends Controller
}
$educationalInstitution->delete();
return redirect()->route('educational_institutions.index');
return redirect()->route('educational-institutions.index');
}
}

View File

@ -1,10 +1,9 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreFacultyRequest;
use App\Http\Requests\admin\Catalog\UpdateFacultyRequest;
use App\Http\Requests\StoreFacultyRequest;
use App\Http\Requests\UpdateFacultyRequest;
use App\Models\EducationalInstitution;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory;
@ -17,13 +16,13 @@ class FacultyController extends Controller
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$faculties = Faculty::all();
return view('admin.catalog.faculty.index', compact('faculties'));
return view('catalog.faculty.index', compact('faculties'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$educationalInstitutions = EducationalInstitution::pluck('name', 'id');
return view('admin.catalog.faculty.create', compact('educationalInstitutions'));
return view('catalog.faculty.create', compact('educationalInstitutions'));
}
public function store(StoreFacultyRequest $request): RedirectResponse
@ -34,22 +33,16 @@ class FacultyController extends Controller
$faculty->name = $validated['name'];
$faculty->description = $validated['description'];
$faculty->position = $validated['position'];
$faculty->slug = $validated['slug'];
$faculty->educational_institution_id = $validated['educational_institution_id'];
$faculty->save();
return redirect()->route('faculties.index');
}
public function show(Faculty $faculty): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
return view('admin.catalog.faculty.show', compact('faculty'));
}
public function edit(Faculty $faculty): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$educationalInstitutions = EducationalInstitution::pluck('name', 'id');
return view('admin.catalog.faculty.edit', compact('faculty', 'educationalInstitutions'));
return view('catalog.faculty.edit', compact('faculty', 'educationalInstitutions'));
}
public function update(UpdateFacultyRequest $request, Faculty $faculty): RedirectResponse
@ -59,7 +52,6 @@ class FacultyController extends Controller
$faculty->name = $validated['name'];
$faculty->description = $validated['description'];
$faculty->position = $validated['position'];
$faculty->slug = $validated['slug'];
$faculty->educational_institution_id = $validated['educational_institution_id'];
$faculty->save();
@ -68,9 +60,6 @@ class FacultyController extends Controller
public function destroy(Faculty $faculty): RedirectResponse
{
if ($faculty->departments()->exists()) {
return back();
}
$faculty->delete();
return redirect()->route('faculties.index');
}

View File

@ -0,0 +1,109 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreFileRequest;
use App\Http\Requests\StoreReceptionScreenRequest;
use App\Http\Requests\UpdateFileRequest;
use App\Http\Requests\UpdateReceptionScreenRequest;
use App\Models\File;
use App\Models\ReceptionScreen;
use App\Services\WorkWithFiles;
use Carbon\Carbon;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
class FileController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::guest(), 403);
$files = File::all()->sortBy('position');
return view('files.index', compact('files'));
}
public function create($idReceptionScreen = null): View
{
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::pluck('name', 'id');
$files = File::where('reception_screen_id', '=', $idReceptionScreen)->get();
return view('files.create', compact('receptionScreens', 'idReceptionScreen', 'files'));
}
public function store(StoreFileRequest $request)
{
abort_if(Auth::guest(), 403);
$nameFile = $request->file('url')->getClientOriginalName();
$name = Storage::put('public', $request->file('url'));
$validated = $request->validated();
$file = new File();
$file->name = $validated['name'];
$file->file_name = $nameFile;
$file->url = Storage::url($name);
$file->position = $validated['position'];
$file->reception_screen_id = $validated['idReceptionScreen'];
$file->save();
return redirect()->route('files.index');
}
public function download($id)
{
$file = (new File())->find($id);
return Storage::url($file->url);
}
public function edit(int $idFile)
{
abort_if(Auth::guest(), 403);
$file = (new File())->find($idFile);
$files = File::where('reception_screen_id', '=', $file->reception_screen_id)->get();
$receptionScreens = ReceptionScreen::pluck('name', 'id');
$idsReceptionScreens = $receptionScreens->keys()->toArray();
$idReceptionScreen = $file->reception_screen_id;
return view(
'files.edit',
compact(
'receptionScreens',
'idsReceptionScreens',
'idReceptionScreen',
'files',
'file'
)
);
}
public function update(UpdateFileRequest $request, File $file)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$file->name = $validated['name'];
$file->position = $validated['position'];
$file->reception_screen_id = $validated['idReceptionScreen'];
$file->save();
return redirect()->route('admin-reception-screen.index');
}
public function destroy($idFile)
{
abort_if(Auth::guest(), 403);
$file = (new File())->find($idFile);
$file->delete();
return redirect()->route('admin-reception-screen.index');
}
}

View File

@ -1,18 +1,19 @@
<?php
namespace App\Http\Controllers\admin;
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Admission;
use App\Models\ReceptionScreen;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class PageController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$admissions = Admission::all()->sortBy('position');
return view('menu.reception-screen', compact('admissions'));
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('menu.reception-screen', compact('receptionScreens'));
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreReceptionScreenRequest;
use App\Http\Requests\UpdateReceptionScreenRequest;
use App\Models\ReceptionScreen;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class ReceptionScreenController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('receptionScreens'));
}
public function create(): View
{
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.create', compact('receptionScreens'));
}
public function store(StoreReceptionScreenRequest $request)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$receptionScreen->name = $validated['name'];
$receptionScreen->position = $validated['position'];
$receptionScreen->save();
return redirect()->route('admin-reception-screen.index');
}
public function edit($id)
{
abort_if(Auth::guest(), 403);
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
$receptionScreens = $receptionScreen->all()->sortBy('position');
return view('admin-reception-screen.edit', compact('currentReceptionScreen', 'receptionScreens'));
}
public function update(UpdateReceptionScreenRequest $request, $id)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
$currentReceptionScreen->name = $validated['name'];
$currentReceptionScreen->position = $validated['position'];
$currentReceptionScreen->save();
return redirect()->route('admin-reception-screen.index');
}
public function destroy($id)
{
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);
if ($currentReceptionScreen->files()->exists()) {
return back();
}
$currentReceptionScreen->delete();
return redirect()->route('admin-reception-screen.index');
}
}

View File

@ -1,10 +1,10 @@
<?php
namespace App\Http\Controllers\admin;
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\UpdateUserRequest;
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;
@ -17,15 +17,14 @@ class UserController extends Controller
{
public function __construct()
{
$this->authorizeResource(User::class, 'user');
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::user()->name !== 'admin', 403);
$users = User::all();
return view('admin.users.index', compact('users'));
return view('users.index', compact('users'));
}
public function store(UpdateUserRequest $request): RedirectResponse
@ -47,14 +46,14 @@ class UserController extends Controller
{
abort_if(Auth::user()->name !== 'admin', 403);
return view('admin.users.create');
return view('users.create');
}
public function edit(User $user): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::user()->name !== 'admin', 403);
return view('admin.users.edit', compact('user'));
return view('users.edit', compact('user'));
}
public function update(UpdateUserRequest $request, User $user): RedirectResponse

View File

@ -1,72 +0,0 @@
<?php
namespace App\Http\Controllers\admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\StoreAdmissionRequest;
use App\Http\Requests\admin\UpdateAdmissionRequest;
use App\Models\Admission;
class AdmissionController extends Controller
{
public function index()
{
$admissions = Admission::all()->sortBy('position');
return view('admin.admission.index', compact('admissions'));
}
public function create()
{
$admissions = Admission::all()->sortBy('position');
return view('admin.admission.create', compact('admissions'));
}
public function store(StoreAdmissionRequest $request)
{
$validated = $request->validated();
$admission = new Admission();
$admission->name = $validated['name'];
$admission->description = $validated['description'];
$admission->slug = $validated['slug'];
$admission->position = $validated['position'];
$admission->save();
return redirect()->route('admissions.index');
}
public function show(Admission $admission)
{
return view('admin.admission.show', compact('admission'));
}
public function edit(Admission $admission)
{
return view('admin.admission.edit', compact('admission'));
}
public function update(UpdateAdmissionRequest $request, Admission $admission)
{
$validated = $request->validated();
$admission->name = $validated['name'];
$admission->description = $validated['description'];
$admission->slug = $validated['slug'];
$admission->position = $validated['position'];
$admission->save();
return redirect()->route('admissions.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Admission $admission)
{
if ($admission->documents()->exists()) {
return back();
}
$admission->delete();
return redirect()->route('admissions.index');
}
}

View File

@ -1,79 +0,0 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreDepartmentRequest;
use App\Http\Requests\admin\Catalog\UpdateDepartmentRequest;
use App\Models\Department;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
class DepartmentController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$departments = Department::all();
return view('admin.catalog.department.index', compact('departments'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$faculties = Faculty::pluck('name', 'id');
return view('admin.catalog.department.create', compact('faculties'));
}
public function store(StoreDepartmentRequest $request): RedirectResponse
{
$validated = $request->validated();
$department = new Department();
$department->name = $validated['name'];
$department->description = $validated['description'];
$department->position = $validated['position'];
$department->faculty_id = $validated['faculty_id'];
$department->slug = $validated['slug'];
$department->save();
return redirect()->route('departments.index');
}
public function show(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$faculty = Faculty::find($department->faculty->id);
$educationalInstitution = $faculty->educationalInstitution;
return view('admin.catalog.department.show', compact('department', 'faculty', 'educationalInstitution'));
}
public function edit(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$faculties = Faculty::pluck('name', 'id');
return view('admin.catalog.department.edit', compact('department', 'faculties'));
}
public function update(UpdateDepartmentRequest $request, Department $department): RedirectResponse
{
$validated = $request->validated();
$department->name = $validated['name'];
$department->description = $validated['description'];
$department->position = $validated['position'];
$department->faculty_id = $validated['faculty_id'];
$department->slug = $validated['slug'];
$department->save();
return redirect()->route('departments.index');
}
public function destroy(Department $department): RedirectResponse
{
if ($department->directions()->exists()) {
return back();
}
$department->delete();
return redirect()->route('departments.index');
}
}

View File

@ -1,99 +0,0 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreDirectionRequest;
use App\Http\Requests\admin\Catalog\UpdateDirectionRequest;
use App\Models\Department;
use App\Models\Direction;
use App\Models\EducationForm;
use App\Models\EducationLevel;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
class DirectionController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$directions = Direction::all();
return view('admin.catalog.direction.index', compact('directions'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$levels = EducationLevel::pluck('name', 'id');
$forms = EducationForm::pluck('name', 'id');
$departments = Department::pluck('name', 'id');
return view('admin.catalog.direction.create', compact('departments', 'levels', 'forms'));
}
public function store(StoreDirectionRequest $request): RedirectResponse
{
$validated = $request->validated();
$direction = new Direction();
$direction->name = $validated['name'];
$direction->description = $validated['description'];
$direction->position = $validated['position'];
$direction->slug = $validated['slug'];
$direction->code = $validated['code'];
$direction->education_level_id = $validated['education_level_id'];
$direction->education_form_id = $validated['education_form_id'];
$direction->department_id = $validated['department_id'];
$direction->save();
return redirect()->route('directions.index');
}
public function show(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$department = $direction->department;
$faculty = Faculty::find($department->faculty->id);
$educationalInstitution = $faculty->educationalInstitution;
return view(
'admin.catalog.direction.show',
compact(
'direction',
'educationalInstitution',
'faculty',
'department',
)
);
}
public function edit(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$levels = EducationLevel::pluck('name', 'id');
$departments = Department::pluck('name', 'id');
$forms = EducationForm::pluck('name', 'id');
return view('admin.catalog.direction.edit', compact('direction', 'departments', 'levels', 'forms'));
}
public function update(UpdateDirectionRequest $request, Direction $direction): RedirectResponse
{
$validated = $request->validated();
$direction = new Direction();
$direction->name = $validated['name'];
$direction->description = $validated['description'];
$direction->position = $validated['position'];
$direction->slug = $validated['slug'];
$direction->code = $validated['code'];
$direction->education_level_id = $validated['education_level_id'];
$direction->education_form_id = $validated['education_form_id'];
$direction->department_id = $validated['department_id'];
$direction->save();
return redirect()->route('directions.index');
}
public function destroy(Direction $direction): RedirectResponse
{
$direction->delete();
return redirect()->route('directions.index');
}
}

View File

@ -1,69 +0,0 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreEducationFormRequest;
use App\Http\Requests\admin\Catalog\UpdateEducationFormRequest;
use App\Models\EducationForm;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
class EducationFormController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$forms = EducationForm::all();
return view('admin.catalog.education_form.index', compact('forms'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
return view('admin.catalog.education_form.create');
}
public function store(StoreEducationFormRequest $request)
{
$validated = $request->validated();
$form = new EducationForm();
$form->name = $validated['name'];
$form->description = $validated['description'];
$form->slug = $validated['slug'];
$form->save();
return redirect()->route('education_forms.index');
}
public function show(EducationForm $educationForm): View|Factory|\Illuminate\Contracts\Foundation\Application
{
$directions = $educationForm->directions;
return view('admin.catalog.education_form.show', compact('educationForm', 'directions'));
}
public function edit(EducationForm $educationForm)
{
return view('admin.catalog.education_form.edit', compact('educationForm'));
}
public function update(UpdateEducationFormRequest $request, EducationForm $educationForm)
{
$validated = $request->validated();
$educationForm->name = $validated['name'];
$educationForm->description = $validated['description'];
$educationForm->slug = $validated['slug'];
$educationForm->save();
return redirect()->route('education_forms.index');
}
public function destroy(EducationForm $educationForm)
{
if ($educationForm->directions()->exists()) {
return back();
}
$educationForm->delete();
return redirect()->route('education_forms.index');
}
}

View File

@ -1,74 +0,0 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreEducationLevelRequest;
use App\Http\Requests\admin\Catalog\UpdateEducationLevelRequest;
use App\Models\EducationLevel;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
class EducationLevelController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$levels = EducationLevel::all();
return view('admin.catalog.education_level.index', compact('levels'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
return view('admin.catalog.education_level.create');
}
public function store(StoreEducationLevelRequest $request): RedirectResponse
{
$validated = $request->validated();
$level = new EducationLevel();
$level->name = $validated['name'];
$level->description = $validated['description'];
$level->slug = $validated['slug'];
$level->save();
return redirect()->route('education_levels.index');
}
public function show(
EducationLevel $educationLevel
): View|Application|Factory|\Illuminate\Contracts\Foundation\Application {
$directions = $educationLevel->directions();
return view(
'admin.catalog.education_level.show',
compact('educationLevel', 'directions')
);
}
public function edit(EducationLevel $educationLevel)
{
return view('admin.catalog.education_level.edit', compact('educationLevel'));
}
public function update(UpdateEducationLevelRequest $request, EducationLevel $educationLevel): RedirectResponse
{
$validated = $request->validated();
$educationLevel->name = $validated['name'];
$educationLevel->description = $validated['description'];
$educationLevel->slug = $validated['slug'];
$educationLevel->save();
return redirect()->route('education_levels.index');
}
public function destroy(EducationLevel $educationLevel)
{
if ($educationLevel->directions()->exists()) {
return back();
}
$educationLevel->delete();
return redirect()->route('education_levels.index');
}
}

View File

@ -1,99 +0,0 @@
<?php
namespace App\Http\Controllers\admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\StoreDocumentRequest;
use App\Http\Requests\admin\UpdateDocumentRequest;
use App\Models\Admission;
use App\Models\Document;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Storage;
class DocumentController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$documents = Document::all();
return view('admin.documents.index', compact('documents'));
}
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$admissions = Admission::pluck('name', 'id');
return view('admin.documents.create', compact('admissions'));
}
public function store(StoreDocumentRequest $request): RedirectResponse
{
$this->saveFile($request);
return redirect()->route('documents.index');
}
public function edit(Document $document)
{
$admissions = Admission::pluck('name', 'id');
return view('admin.documents.edit', compact('admissions', 'document'));
}
public function show(Document $document): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
return view('admin.documents.show', compact('document'));
}
public function update(UpdateDocumentRequest $request, Document $document): RedirectResponse
{
$validated = $request->validated();
$document->name = $validated['name'];
$document->description = $validated['description'];
$document->position = $validated['position'];
$document->admission_id = $validated['admission_id'];
$document->save();
return redirect()->route('documents.index');
}
public function destroy(Document $document)
{
$document->delete();
return redirect()->route('documents.index');
}
public function download($id)
{
$file = (new Document())->find($id);
return Storage::url($file->url);
}
public function createFromAdmission(Admission $admission): View
{
$admissions = Admission::pluck('name', 'id');
$documents = Document::where('admission_id', '=', $admission->id)->get();
return view('admin.documents.create_from_admission', compact('admissions', 'admission', 'documents'));
}
public function storeFromAdmission(StoreDocumentRequest $request): RedirectResponse
{
$this->saveFile($request);
return redirect()->route('admissions.index');
}
private function saveFile(StoreDocumentRequest $request)
{
$fileName = $request->file('document')->getClientOriginalName();
$name = Storage::put('public', $request->file('document'));
$validated = $request->validated();
$document = new Document();
$document->name = $validated['name'];
$document->description = $validated['description'];
$document->file_name = $fileName;
$document->url = Storage::url($name);
$document->position = $validated['position'];
$document->admission_id = $validated['admission_id'];
$document->save();
}
}

View File

@ -1,23 +1,30 @@
<?php
namespace App\Http\Requests\admin\Catalog;
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreEducationalInstitutionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'position' => 'int|max:255',
'name' => 'required|string|max:255|unique:educational_institutions,name',
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreFacultyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'position' => 'int|max:255',
'name' => 'required|string|max:255|unique:educational_institutions,name',
'description' => 'string',
'educational_institution_id' => 'int'
];
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreFileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'max:255',
'position' => 'int|max:255',
'url' => 'file',
'idReceptionScreen' => 'int|max:255',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreReceptionScreenRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|max:255',
'position' => 'required||int|max:255',
];
}
}

View File

@ -1,21 +1,31 @@
<?php
namespace App\Http\Requests\admin;
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreUserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'name' => 'required|unique:users,name|max:255',
'email' => 'email|string|max:255',
'email' => 'email',
'password' => 'required'
];
}

View File

@ -1,23 +1,31 @@
<?php
namespace App\Http\Requests\admin\Catalog;
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateEducationalInstitutionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'position' => 'int|max:255',
'description' => 'string',
'slug' => 'required|string|max:255',
'name' => [
'required',
'string',

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateFacultyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'position' => 'int|max:255',
'name' => 'required|string|max:255|unique:educational_institutions,name',
'description' => 'string',
'educational_institution_id' => 'int'
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateFileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|max:255',
'position' => 'required||int|max:255',
'idReceptionScreen' => 'int|max:255',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateReceptionScreenRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|max:255',
'position' => 'required||int|max:255',
];
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Http\Requests\admin;
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
@ -24,9 +24,9 @@ class UpdateUserRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|string|max:255',
'email' => 'email|string|max:255',
'password' => 'required|max:255'
'name' => 'required|max:255',
'email' => 'email',
'password' => 'required'
];
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreDepartmentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:departments,name',
'description' => 'string',
'slug' => 'required|string|max:255',
'faculty_id' => 'required|numeric|int|max:1000',
];
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class StoreDirectionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:directions,name',
'description' => 'string',
'slug' => 'required|string|max:255',
'code' => 'required|string|max:255',
'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000',
'department_id' => 'required|numeric|int|max:1000'
];
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class StoreEducationFormRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => 'required|string|max:255|unique:education_levels,name',
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class StoreEducationLevelRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => 'required|string|max:255|unique:education_levels,name',
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreFacultyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:faculties,name',
'description' => 'string',
'slug' => 'required|string|max:255',
'educational_institution_id' => 'required|int|numeric|max:1000'
];
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDepartmentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'description' => 'string',
'slug' => 'string|required|max:255',
'faculty_id' => 'int|required|numeric|max:255',
'name' => [
'required',
'string',
'max:255',
"unique:departments,name,{$this->department->id}",
],
];
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDirectionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required||numeric|int|max:255',
'description' => 'string',
'department_id' => 'int|required|numeric|max:1000',
'slug' => 'required|string|max:255',
'code' => 'required|string|max:255',
'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000',
'name' => [
'required',
'string',
'max:255',
"unique:directions,name,{$this->direction->id}",
],
];
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class UpdateEducationFormRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => "required|string|max:255|unique:education_forms,name,{$this->education_form->id}",
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class UpdateEducationLevelRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => "required|string|max:255|unique:education_levels,name,{$this->education_level->id}",
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Http\Requests\admin\Catalog;
use Illuminate\Foundation\Http\FormRequest;
class UpdateFacultyRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'description' => 'string',
'slug' => 'required|string|max:255',
'educational_institution_id' => 'required|int|numeric|max:255',
'name' => [
'required',
'string',
'max:255',
"unique:faculties,name,{$this->faculty->id}",
],
];
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreAdmissionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:admissions,name',
'description' => 'string',
'slug' => 'required|string|max:255',
];
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreDocumentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'description' => 'string',
'position' => 'required|int|numeric|max:255',
'document' => 'required|file',
'admission_id' => 'required|int|numeric|max:1000',
];
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Foundation\Http\FormRequest;
class UpdateAdmissionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'position' => 'required|int|numeric|max:255',
'description' => 'string',
'slug' => 'string|required|max:255',
'name' => [
'required',
'string',
'max:255',
"unique:admissions,name,{$this->admission->id}",
],
];
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDocumentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => [
'required',
'string',
'max:255',
"unique:documents,name,{$this->document->id}",
],
'position' => 'required|int|numeric|max:255',
'description' => 'string',
'admission_id' => 'required|int|numeric|max:1000',
];
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Department extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'slug',
'description',
'position',
];
public function faculty(): BelongsTo
{
return $this->belongsTo(Faculty::class);
}
public function directions(): HasMany
{
return $this->hasMany('App\Models\Direction', 'department_id');
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Direction extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'description',
'position',
'slug',
'code',
];
public function department(): BelongsTo
{
return $this->belongsTo(Department::class);
}
public function educationLevel(): BelongsTo
{
return $this->belongsTo(EducationLevel::class);
}
public function educationForm(): BelongsTo
{
return $this->belongsTo(EducationForm::class);
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class EducationForm extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'description',
'slug',
];
public function directions(): HasMany
{
return $this->hasMany('App\Models\Direction', 'education_form_id');
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class EducationLevel extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'description',
'slug',
];
public function directions(): HasMany
{
return $this->hasMany('App\Models\Direction', 'education_level_id');
}
}

View File

@ -13,7 +13,6 @@ class EducationalInstitution extends Model
protected $fillable = [
'id',
'name',
'slug',
'description',
'position',
];

View File

@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Faculty extends Model
{
@ -15,7 +14,6 @@ class Faculty extends Model
'id',
'name',
'description',
'slug',
'position',
];
@ -23,9 +21,4 @@ class Faculty extends Model
{
return $this->belongsTo(EducationalInstitution::class);
}
public function departments(): HasMany
{
return $this->hasMany('App\Models\Department', 'faculty_id');
}
}

View File

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Document extends Model
class File extends Model
{
use HasFactory;
@ -18,8 +18,8 @@ class Document extends Model
'description',
];
public function admission(): BelongsTo
public function receptionScreen(): BelongsTo
{
return $this->belongsTo(Admission::class);
return $this->belongsTo(ReceptionScreen::class);
}
}

View File

@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Admission extends Model
class ReceptionScreen extends Model
{
use HasFactory;
@ -16,8 +16,8 @@ class Admission extends Model
'position'
];
public function documents(): HasMany
public function files(): HasMany
{
return $this->hasMany('App\Models\Document', 'admission_id');
return $this->hasMany('App\Models\File', 'reception_screen_id');
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\EducationalInstitution;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class EducationalInstitutionPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
//
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, EducationalInstitution $educationalInstitution): bool
{
//
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
//
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, EducationalInstitution $educationalInstitution): bool
{
//
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, EducationalInstitution $educationalInstitution): bool
{
//
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, EducationalInstitution $educationalInstitution): bool
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, EducationalInstitution $educationalInstitution): bool
{
//
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Faculty;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class FacultyPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
//
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Faculty $faculty): bool
{
//
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
//
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Faculty $faculty): bool
{
//
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Faculty $faculty): bool
{
//
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Faculty $faculty): bool
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Faculty $faculty): bool
{
//
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\ReceptionScreen;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class ReceptionScreenPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
//
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ReceptionScreen $doceumentsOnline): bool
{
//
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
//
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ReceptionScreen $doceumentsOnline): bool
{
//
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ReceptionScreen $doceumentsOnline): bool
{
//
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, ReceptionScreen $doceumentsOnline): bool
{
//
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, ReceptionScreen $doceumentsOnline): bool
{
//
}
}

View File

@ -1,65 +0,0 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class UserPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, User $model): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, User $model): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, User $model): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, User $model): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, User $model): bool
{
return $user->name === config('app.admin_name') && $user->email === config('app.admin_email');
}
}

View File

@ -3,8 +3,6 @@
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use App\Models\User;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
@ -15,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array<class-string, class-string>
*/
protected $policies = [
User::class => UserPolicy::class,
//
];
/**

View File

@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @var string
*/
public const HOME = '/admin/dashboard';
public const HOME = '/dashboard';
/**
* Define your route model bindings, pattern filters, and other route configuration.

View File

@ -4,11 +4,71 @@ namespace App\Services;
use DiDom\Document;
/*
class PageScrapper
{
private string $url;
private string $contentMarker;
public function __construct($url, $contentMarker = '<div class=["\']content_info["\']>')
{
$this->url = $url;
$this->contentMarker = $contentMarker;
}
public function getHTML()
{
$page = file_get_contents($this->url);
$strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/is";
$arr = [];
$rez = preg_match_all($strForPregMatch, $page, $arr);
return $content = $arr[0][0];
}
public function normalizeURLFile($content)
{
$rez = preg_match_all('/<a href="(.*)">/isU', $content, $arr);
$arr[1] = array_unique($arr[1]);
foreach ($arr[1] as $el) {
if (!str_starts_with($el, 'https')) {
$content = str_replace($el, 'https://mkgtu.ru' . $el, $content);
}
}
$rez = preg_match_all('/src="(.*)">/isU', $content, $arr);
$arr[1] = array_unique($arr[1]);
foreach ($arr[1] as $el) {
if (!str_starts_with($el, 'https') && str_contains($el, 'upload')) {
$content = str_replace($el, 'https://mkgtu.ru' . $el, $content);
}
}
return $content;
}
public function cutHTML($content, $strForScissors)
{
$arr = [];
//<footer(.*)<\/footer>
//safdsaf sdfdasf<footer>--------------------------------fsdfdasf <\/footer> asdfdasf asdf
$rez = preg_match_all($strForScissors, $content, $arr);
//$arr[1][0] = '>--------------------------------fsdfdasf ';
$content = str_replace($arr[0], '', $content);
//safdsaf sdfdasf<footer<\/footer> asdfdasf asdf
return $content;
}
}
*/
class PageScrapper
{
private string $url;
private string $contentMarker;
private Document $document;
public function __construct($url, $contentMarker)
{
@ -16,19 +76,16 @@ class PageScrapper
$this->contentMarker = $contentMarker;
$this->document = new Document($this->url, true);
}
public function getFullHTML()
{
return $this->document;
}
public function printHTML()
{
$rez = $this->document;
$content = $rez->first($this->contentMarker)->html();
return $content;
}
public function normalizePath()
{
$rez = $this->document;
@ -57,6 +114,10 @@ class PageScrapper
}
foreach ($srclinks as $k => $srclink) {
$src = $srclink->attr('src');
if (!str_contains($srclink->attr('src'), "https://")) {
@ -65,6 +126,23 @@ class PageScrapper
$html0 = str_replace(urldecode($unchanged), $changed, $html0);
}
}
// foreach ($srclinks as $k => $srclink) {
// $src = $srclink->attr('src');
//
// if (!str_contains($srclink->attr('src'), "https://")) {
//
//
// $tmp = explode('/', rawurldecode($src));
// foreach ( $tmp as $k => $v) {
// $tmp[$k] = rawurlencode($v);
// }
// $src = implode('/', $tmp);
//
//
// $html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0);
// }
// }
// str_replace('st yle', 'style', $html0);
return $html0;
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Services;
use Carbon\Carbon;
class WorkWithFiles
{
public static function saveFileToUploads($content)
{
$destinationPath = 'uploads';
$content->move($destinationPath, $content->getClientOriginalName());
}
public static function renameFile($content)
{
$nameChunks = explode('.', $content->getClientOriginalName());
array_splice($nameChunks, 1);
$timestamp = Carbon::now();
$name = implode('.', $nameChunks);
$newName = "{$name}{$timestamp}.{$content->getClientOriginalExtension()}";
$dir = __DIR__;
$path = "{$dir}/../../public/uploads/";
$oldName = $content->getClientOriginalName();
rename("{$path}{$oldName}", "{$path}{$newName}");
return "{$path}{$newName}";
}
}

View File

@ -185,6 +185,4 @@ return [
// 'Example' => App\Facades\Example::class,
])->toArray(),
'admin_name' => env('ADMIN_NAME'),
'admin_email' => env('ADMIN_EMAIL')
];

View File

@ -1,18 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class AdmissionFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
'position' => fake()->randomDigit(),
];
}
}

View File

@ -1,19 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class DepartmentFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
'position' => fake()->randomDigit(),
'faculty_id' => 1,
];
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class DirectionFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
'code' => fake()->text(50),
'position' => fake()->randomDigit(),
'department_id' => 1,
'education_level_id' => 1,
'education_form_id' => 1,
];
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class DocumentFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'file_name' => fake()->name(),
'description' => fake()->text(),
'url' => fake()->url(),
'position' => fake()->randomDigit(),
'admission_id' => 1,
];
}
}

View File

@ -1,17 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class EducationFormFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
];
}
}

View File

@ -1,17 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
class EducationLevelFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
];
}
}

View File

@ -4,15 +4,20 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EducationalInstitution>
*/
class EducationalInstitutionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'slug' => fake()->slug(),
'position' => fake()->randomDigit(),
//
];
}
}

View File

@ -4,16 +4,20 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Faculty>
*/
class FacultyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'description' => fake()->text(),
'position' => fake()->randomDigit(),
'slug' => fake()->slug(),
'educational_institution_id' => 1,
//
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ReceptionScreen>
*/
class ReceptionScreenFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
@ -19,6 +22,9 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');

View File

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
@ -15,6 +18,9 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');

View File

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
@ -19,6 +22,9 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');

View File

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
@ -20,6 +23,9 @@ return new class extends Migration
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');

View File

@ -6,20 +6,24 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admissions', function (Blueprint $table) {
Schema::create('reception_screens', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('slug');
$table->integer('position');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admissions');
Schema::dropIfExists('reception_screens');
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('submenu', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description');
$table->string('parent');
$table->string('meta_title');
$table->string('meta_description');
$table->string('meta_keywords');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('submenu');
}
};

View File

@ -6,22 +6,28 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documents', function (Blueprint $table) {
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('file_name')->nullable();
$table->text('description')->nullable();
$table->string('description')->nullable();
$table->string('url');
$table->integer('position');
$table->foreignId('admission_id')->constrained('admissions');
$table->foreignId('reception_screen_id')->constrained('reception_screens');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documents');
Schema::dropIfExists('files');
}
};

View File

@ -6,18 +6,23 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('educational_institutions', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->text('description')->nullable();
$table->text('description');
$table->integer('position');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('educational_institutions');

View File

@ -6,19 +6,24 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('faculties', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('description');
$table->integer('position');
$table->string('slug');
$table->foreignId('educational_institution_id')->constrained('educational_institutions');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('faculties');

View File

@ -1,26 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('departments', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->integer('position');
$table->string('slug');
$table->foreignId('faculty_id')->constrained('faculties');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('departments');
}
};

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('education_levels', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('slug');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('education_levels');
}
};

View File

@ -1,29 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('directions', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('code');
$table->integer('position');
$table->string('slug');
$table->foreignId('department_id')->constrained('departments');
$table->foreignId('education_level_id')->constrained('education_levels');
$table->foreignId('education_form_id')->constrained('education_forms');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('directions');
}
};

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('education_forms', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('slug');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('education_forms');
}
};

View File

@ -1,37 +0,0 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AdmissionSeeder extends Seeder
{
public function run(): void
{
DB::table('admissions')->insert([
[
'name' => 'Пункт 1',
'position' => 2,
'description' => 'description 1',
'slug' => 'point-1',
'created_at' => now(),
],
[
'name' => 'Пункт 2',
'position' => 3,
'description' => 'description 2',
'slug' => 'point-2',
'created_at' => now(),
],
[
'name' => 'Пункт 3',
'description' => 'description 3',
'position' => 1,
'slug' => 'point-3',
'created_at' => now(),
]
]);
}
}

View File

@ -2,6 +2,7 @@
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\User;
use Illuminate\Database\Seeder;
@ -12,26 +13,16 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
//
User::factory()->create([
'name' => config('app.admin_name'),
'email' => config('app.admin_email'),
'name' => 'admin',
'email' => 'test@example.com',
'password' => 123456
]);
User::factory(10)->create();
$this->call([
EducationalInstitutionSeeder::class,
FacultySeeder::class,
DepartmentSeeder::class,
EducationLevelSeeder::class,
EducationFormSeeder::class,
DirectionSeeder::class,
]);
$this->call([
AdmissionSeeder::class,
DocumentSeeder::class,
ReceptionScreenSeeder::class,
FileSeeder::class
]);
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DepartmentSeeder extends Seeder
{
public function run(): void
{
DB::table('departments')->insert([
[
'name' => 'Кафедра инф. без.',
'description' => 'Кафедра инф. без. описание',
'position' => 1,
'slug' => 'departmentInfWithout',
'faculty_id' => 1,
],
[
'name' => 'кафедра стоматологии',
'description' => 'кафедра стоматологии описание',
'position' => 2,
'slug' => 'departmentOfDentistry',
'faculty_id' => 2,
],
]);
}
}

View File

@ -1,46 +0,0 @@
<?php
namespace Database\Seeders;
use App\Models\Direction;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DirectionSeeder extends Seeder
{
public function run(): void
{
DB::table('directions')->insert([
[
'name' => 'Юриспруденция',
'description' => 'Юриспруденция',
'slug' => 'jurisprudence',
'code' => '40.03.01',
'position' => 1,
'department_id' => 1,
'education_level_id' => 1,
'education_form_id' => 1,
],
[
'name' => 'фармация',
'description' => 'фармация',
'slug' => 'pharmacy',
'code' => '33.05.01',
'position' => 2,
'department_id' => 1,
'education_level_id' => 2,
'education_form_id' => 2,
],
[
'name' => 'строительство',
'description' => 'строительство',
'slug' => 'construction',
'code' => '08.04.01',
'position' => 3,
'department_id' => 1,
'education_level_id' => 3,
'education_form_id' => 3,
],
]);
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class EducationFormSeeder extends Seeder
{
public function run(): void
{
DB::table('education_forms')->insert([
[
'name' => 'очная',
'description' => 'очная',
'slug' => 'full-time',
],
[
'name' => 'заочная',
'description' => 'специалитет',
'slug' => 'part-time',
],
[
'name' => 'очно-заочная',
'description' => 'очно-заочная',
'slug' => 'blended',
],
]);
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class EducationLevelSeeder extends Seeder
{
public function run(): void
{
DB::table('education_levels')->insert([
[
'name' => 'бакалавриат',
'description' => 'бакалавриат',
'slug' => 'baccalaureate',
],
[
'name' => 'специалитет',
'description' => 'специалитет',
'slug' => 'specialty',
],
[
'name' => 'магитсратура',
'description' => 'магитсратура',
'slug' => 'magistracy',
],
]);
}
}

View File

@ -2,10 +2,8 @@
namespace Database\Seeders;
use App\Models\EducationalInstitution;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class EducationalInstitutionSeeder extends Seeder
{
@ -14,19 +12,6 @@ class EducationalInstitutionSeeder extends Seeder
*/
public function run(): void
{
DB::table('educational_institutions')->insert([
[
'name' => 'МГТУ',
'description' => 'ФГБОУ ВО Майкопский государственный технологический университет',
'slug' => 'mkgtu',
'position' => 1,
],
[
'name' => 'Педколледж',
'description' => 'ФГБОУ СПО Педагогический колледж',
'slug' => 'pedcollege',
'position' => 1,
],
]);
//
}
}

View File

@ -2,10 +2,8 @@
namespace Database\Seeders;
use App\Models\Faculty;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class FacultySeeder extends Seeder
{
@ -14,22 +12,6 @@ class FacultySeeder extends Seeder
*/
public function run(): void
{
// Faculty::factory(3)->create();
DB::table('faculties')->insert([
[
'name' => 'Информационная безопасность',
'description' => 'Факультет информационной безопасности описание',
'position' => 1,
'slug' => 'new-slug-inf',
'educational_institution_id' => 1,
],
[
'name' => 'Лечебный факультет',
'description' => 'Факультет Лечебный описание',
'position' => 1,
'slug' => 'new-slug-med',
'educational_institution_id' => 2,
],
]);
//
}
}

View File

@ -2,43 +2,42 @@
namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DocumentSeeder extends Seeder
class FileSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('documents')->insert([
DB::table('files')->insert([
[
'name' => 'файл 1',
'file_name' => 'file1',
'description' => 'description1',
'url' => 'url/url1',
'position' => 2,
'admission_id' => 1,
'created_at' => now(),
'reception_screen_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'файл 2',
'description' => 'description2',
'file_name' => 'file2',
'url' => 'url/url2',
'position' => 3,
'admission_id' => 1,
'created_at' => now(),
'reception_screen_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'файл 3',
'file_name' => 'file3',
'description' => 'description3',
'url' => 'url/url3',
'admission_id' => 1,
'reception_screen_id' => 1,
'position' => 1,
'created_at' => now(),
'created_at' => Carbon::now(),
]
]);
}

View File

@ -0,0 +1,35 @@
<?php
namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ReceptionScreenSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('reception_screens')->insert([
[
'name' => 'Пункт 1 с файлами',
'position' => 2,
'created_at' => Carbon::now(),
],
[
'name' => 'Пункт 2 с файлами',
'position' => 3,
'created_at' => Carbon::now(),
],
[
'name' => 'Пункт 3 с файлами',
'position' => 1,
'created_at' => Carbon::now(),
]
]);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 MiB

32
qodana.yaml Normal file
View File

@ -0,0 +1,32 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
php:
version: 8.3 #(Applied in CI/CD pipeline)
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-php:latest

View File

@ -1,4 +1,4 @@
// import './bootstrap';
import './bootstrap';
import Alpine from 'alpinejs';
import ujs from '@rails/ujs';

View File

@ -1,11 +1,11 @@
@extends('layouts.admin_layout')
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class=""> Создать пункт Экрана приема</h1>
{{ Form::open(['url' => route('admissions.store'), 'method' => 'POST', 'class' => '']) }}
{{ Form::open(['url' => route('admin-reception-screen.store'), 'method' => 'POST', 'class' => '']) }}
<div class="col">
<div>
{{ Form::label('position', 'Позиция') }}
@ -31,30 +31,6 @@
@endif
</div>
<div>
{{ 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>
{{ Form::label('slug', 'URL') }}
</div>
<div class="mt-2">
{{ Form::text('slug', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('description') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
</div>
@ -70,10 +46,10 @@
</tr>
</thead>
<tbody>
@foreach($admissions->sortBy('position') as $admission)
@foreach($receptionScreens as $receptionScreen)
<tr>
<th scope="row">{{ $admission->position }}</th>
<td>{{ $admission->name }}</td>
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
@endforeach
</tbody>
</table>

View File

@ -0,0 +1,60 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class=""> Изменить пункт Экрана приема</h1>
{{ Form::open(['url' => route('admin-reception-screen.update', $currentReceptionScreen), 'method' => 'PATCH', 'class' => '']) }}
<div class="col">
<div>
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', $currentReceptionScreen->position, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('position') }}
@endif
</div>
<div>
{{ Form::label('name', 'Название') }}
</div>
<div class="mt-2">
{{ Form::text('name', $currentReceptionScreen->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
<div class="col">
<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($receptionScreens as $receptionScreen)
<tr>
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
@endforeach
</tbody>
</table>
</div>
</div>
@endauth
@endsection

View File

@ -0,0 +1,144 @@
@extends('layouts.admin-layout')
@section('content')
<style>
.accordion-button:not(.collapsed)
{
color:#006147;
background-color: rgb(255, 255, 255);
box-shadow:inset 0 -1px 0 rgba(0,0,0,.125)
}
.accordion-button:focus {
z-index: 3;
border-color: #006147;
outline: 0;
box-shadow: 0 0 0 0.25rem #006147;
}
</style>
<div class="container">
<h2>Экран Приема</h2>
<br>
<a href="{{ route('admin-reception-screen.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">Позиция</th>
<th scope="col">Название</th>
<th scope="col">действия</th>
<th scope="col"></th>
</tr>
</thead>
<tbody class="accordion" id="accordionExample">
@foreach($receptionScreens as $receptionScreen)
<?php $accordion_tmp = str_replace(' ','', $receptionScreen->name) ?>
<tr class="accordion-item ">
<th scope="row">{{ $receptionScreen->position }}</th>
<td>{{ $receptionScreen->name }}</td>
<td><a href="{{ route("admin-reception-screen.edit", $receptionScreen) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('admin-reception-screen.destroy', $receptionScreen) }}" class="btn btn-danger">
удалить
</a>
</td>
<th class="accordion-header" id="heading<?php echo $accordion_tmp ?>">
<button class="accordion-button collapsed btn btn-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $accordion_tmp ?> " aria-expanded="false" aria-controls="collapse<?php echo $accordion_tmp ?>">
Показать
</button>
</th>
@if(count($receptionScreen->files) !== 0)
</tr>
<tr>
<td colspan="3">
<table class="table table-bordered accordion-collapse collapse" id="collapse<?php echo $accordion_tmp ?>" aria-labelledby="heading<?php echo $accordion_tmp ?>" data-bs-parent="#accordionExample">
<thead class="accordion-body">
<tr>
<th scope="col">Позиция</th>
<th scope="col">Имя Файла</th>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($receptionScreen->files->sortBy('position') as $file)
<tr>
<th scope="row">{{ $file->position }}</th>
<td>{{ $file->name }}</td>
<td><a href="{{ route("files.edit", $file) }}"
class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete"
data-confirm="Вы действительно хотите удалить?"
href="{{ route('files.destroy', $file) }}"
class="btn btn-danger">
удалить
</a>
</td>
</tr>
@endforeach
<tr class=" border border-white border-bottom-0 border-start-0 border-end-0">
<td colspan="3"><div class="mb-2">
<a href="{{ route('files.create', $receptionScreen->id) }}"
class="btn btn-primary">
Добавить файл
</a>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
@else
<tr>
<td colspan="3">
@php($idReceptionScreen = $receptionScreen->id)
<a href="{{ route('files.create', $idReceptionScreen) }}" class="btn btn-primary">Добавить
файл</a>
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endsection

View File

@ -1,4 +1,4 @@
@extends('layouts.admin_layout')
@extends('layouts.admin-layout')
@section('content')

View File

@ -1,66 +0,0 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class=""> Изменить пункт меню Экрана приема</h1>
{{ Form::open(['url' => route('admissions.update', $admission), 'method' => 'PATCH', 'class' => '']) }}
<div class="col">
<div>
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', $admission->position, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('position') }}
@endif
</div>
<div>
{{ Form::label('name', 'Название') }}
</div>
<div class="mt-2">
{{ Form::text('name', $admission->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div>
{{ Form::label('description', 'Описание') }}
</div>
<div class="mt-2">
{{ Form::text('description', $admission->description, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('description') }}
@endif
</div>
<div>
{{ Form::label('slug', 'URL') }}
</div>
<div class="mt-2">
{{ Form::text('slug', $admission->slug, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('description') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }}
</div>
</div>
{{ Form::close() }}
</div>
</div>
@endauth
@endsection

View File

@ -1,109 +0,0 @@
@extends('layouts.admin_layout')
@section('content')
<div class="container">
<h2>Меню экрана приема</h2>
<br>
<a href="{{ route('admissions.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">Позиция</th>
<th scope="col">Название</th>
<th scope="col">действия</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@foreach($admissions as $admission)
<tr class="">
<th scope="row">{{ $admission->position }}</th>
<td><a href="{{ route('admissions.show', $admission) }}">{{ $admission->name }}
@if(count($admission->documents) !== 0)
({{ count($admission->documents) }} файла)
@endif</a></td>
<td>
<a href="{{ route("admissions.edit", $admission) }}"
class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('admissions.destroy', $admission) }}"
class="btn btn-danger">удалить</a>
</td>
@if(count($admission->documents) !== 0)
<td>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseAdmission{{ $admission->id }}" aria-expanded="false"
aria-controls="collapseAdmission{{ $admission->id }}">
Свернуть
</button>
</td>
</tr>
<tr>
<td colspan="3">
<div class="collapse" id="collapseAdmission{{ $admission->id }}">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Позиция</th>
<th scope="col">Имя Файла</th>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($admission->documents as $document)
<tr>
<th scope="row">{{ $document->position }}</th>
<td>{{ $document->name }}</td>
<td><a href="{{ route("documents.edit", $document) }}"
class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete"
data-confirm="Вы действительно хотите удалить?"
href="{{ route('documents.destroy', $document) }}"
class="btn btn-danger">
удалить
</a>
</td>
</tr>
@endforeach
<tr class=" border border-white border-bottom-0 border-start-0 border-end-0">
<td colspan="4">
<div class="mb-2">
<a href="{{ route('document_create_from_admission', $admission) }}"
class="btn btn-primary">
Добавить файл
</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td></td>
</tr>
@else
<td><a class="btn btn-secondary disabled" href=""
role="button">
Сверунть
</a></td>
<tr>
<td colspan="4">
<a href="{{ route('document_create_from_admission', $admission) }}"
class="btn btn-primary">Добавить
файл</a>
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endsection

View File

@ -1,19 +0,0 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
<div class="container mt-4">
<h2>Название</h2>
<p>{{ $admission->name }}</p>
<h2>Описание</h2>
<p>{{ $admission->description }}</p>
<h2>Позиция</h2>
<p>{{ $admission->position }}</p>
<h2>URL</h2>
<p>{{ $admission->slug }}</p>
<h2>Документы</h2>
@foreach($admission->documents as $document)
<p><a href="{{ route('documents.show', $document) }}">{{ $document->name }}</a></p>
@endforeach
</div>
@endauth
@endsection

Some files were not shown because too many files have changed in this diff Show More