diff --git a/.env.example b/.env.example index 2721c55..3d857c4 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,9 @@ 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 diff --git a/.gitea/workflows/php.yml b/.gitea/workflows/php.yml index ed5caab..a9914c3 100644 --- a/.gitea/workflows/php.yml +++ b/.gitea/workflows/php.yml @@ -4,9 +4,9 @@ on: push: branches: - main - pull_request: - branches: - - main +# pull_request: +# branches: +# - main jobs: build: @@ -14,16 +14,23 @@ jobs: strategy: matrix: - php-versions: [ '8.3' ] + php-version: [ '8.3' ] node-version: ['20.x'] + composer-version: ['2.6.6'] steps: - uses: actions/checkout@v4 - - name: Set up PHP ${{ matrix.php-versions }} + - name: Set up PHP ${{ matrix.php-version }} with extensions and tools uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} + ini-values: opcache.enable_cli=1, extension=gd + extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite + tools: composer:${{ matrix.composer-version }} + + env: + debug: true - name: PHP Security Checker uses: StephaneBour/actions-php-security-checker@1.1 @@ -37,22 +44,14 @@ 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 }} # only this works - run: composer install # will work - - - name: Setup sqlite3 driver - run: apt install php${{ matrix.php-versions }}-sqlite3 -y + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }} + run: composer install - name: Setup project - run: make setup + run: make setup-ci - name: Check lint run: make lint @@ -64,7 +63,7 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - name: Checkout + - name: deploy to test server uses: appleboy/ssh-action@v1.0.3 with: @@ -73,7 +72,8 @@ jobs: password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} script: | - cd /var/www/test-testabit/ + cd /var/www/www-root/data/www/testabit.mkgtu.ru git stash git pull --rebase - make setup-test + git stash clear + make setup-prod diff --git a/.gitignore b/.gitignore index 2749dec..71ff04d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ yarn-error.log /_ide_helper.php /_ide_helper_models.php /public/img/icons/play-button.png +/tabit.sql diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4961468 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# syntax = edrevo/dockerfile-plus + +INCLUDE+ Dockerfile.dev + +ENV PORT=80 + +COPY composer.json composer.lock ./ +#COPY app/Helpers/helpers.php ./app/Helpers/helpers.php + +RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader + +COPY package.json package-lock.json ./ + +RUN npm install + +COPY . . + +RUN composer dump-autoload --no-dev --optimize + +RUN npm run prod + +CMD ["bash", "-c", "make db-prepare start-app"] + +EXPOSE ${PORT} diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..deef6c5 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,48 @@ +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=Europe/Moscow +ENV PATH=node_modules/.bin:$PATH + +WORKDIR /app + +RUN apt update && apt upgrade -y + +RUN apt install ca-certificates apt-transport-https software-properties-common lsb-release -y + +RUN add-apt-repository ppa:ondrej/php -y + +RUN apt-get update && apt-get install -y \ + make \ + curl \ + git \ + libpq-dev \ + libzip-dev \ + sqlite3 \ + unzip \ + zip \ + php8.3 \ + php8.3-bcmath \ + php8.3-exif \ + php8.3-pdo \ + php8.3-pgsql \ + php8.3-pgsql \ + php8.3-zip \ + php8.3-xdebug \ + php8.3-dom \ + php8.3-xml \ + php8.3-mbstring \ + php8.3-sqlite3 \ + php8.3-curl + +RUN apt-get update && apt-get install -y \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +COPY ./xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - +RUN apt-get update && apt-get install -y nodejs + +ENV PATH=node_modules/.bin:$PATH diff --git a/Makefile b/Makefile index f53413e..f6c6770 100644 --- a/Makefile +++ b/Makefile @@ -15,16 +15,21 @@ setup: npm run build make ide-helper -setup-test: - composer install --no-plugins --no-scripts +setup-ci: + composer install + cp -n .env.example .env php artisan key:gen --ansi - rm database/database.sqlite touch database/database.sqlite php artisan migrate:refresh php artisan db:seed npm ci npm run build +setup-prod: + /opt/php82/bin/php /usr/local/bin/composer install + npm ci + npm run build + watch: npm run watch @@ -57,3 +62,9 @@ ide-helper: php artisan ide-helper:gen php artisan ide-helper:meta php artisan ide-helper:mod -n + +db-prepare: + php artisan migrate:refresh --force --seed + +start-app: + php artisan serve --host 0.0.0.0 --port ${PORT} diff --git a/README.md b/README.md index fb8085f..18d7cfb 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ git clone http://172.17.254.104/aslan/applicant-site.git cd applicant-site make setup ``` -2255 ## Project start local diff --git a/app/Enums/ExaminationTypeEnum.php b/app/Enums/ExaminationTypeEnum.php new file mode 100644 index 0000000..e9c5c70 --- /dev/null +++ b/app/Enums/ExaminationTypeEnum.php @@ -0,0 +1,10 @@ +code, + $row->name, + $row->department->name, + $row->educationLevel->name, + $row->educationForm->name, + $row->budget_places, + $row->quota, + $row->paid_places, + $row->cost_paid_place, + $row->period, + implode("; ", $row->directionProfiles), + implode("; ", $row->egeCompulsory), + implode("; ", $row->egeOptional), + implode("; ", $row->spo), + implode("; ", $row->magistracy), + ] +// $row->entranceExaminations->name, + ]; + } + + public function prepareRows($rows) + { + return $rows->transform(function ($direction) { + $profilesNames = []; + foreach ($direction->directionProfiles as $profile) { + $profilesNames[] = $profile->name; + } + $direction->directionProfiles = $profilesNames; + + $egeCompulsory = []; + $egeOptional = []; + $spo = []; + $magistracy = []; + foreach ($direction->entranceExaminations as $examination) { + $subject = $examination->subject->name; + $scores = $examination->scores; + if ($examination->examinationType->name === 'ЕГЭ') { + if ($examination->subjectType->name === 'Обязательные') { + $egeCompulsory[] = "{$subject} ({$scores})"; + } elseif ($examination->subjectType->name === 'Предметы по выбору') { + $egeOptional[] = "{$subject} ({$scores})"; + } + } elseif ($examination->examinationType->name === 'СПО') { + $spo[] = "{$subject} ({$scores})"; + } elseif ($examination->examinationType->name === 'магитсратура') { + $magistracy[] = "{$subject} ({$scores})"; + } + } + $direction->egeCompulsory = $egeCompulsory; + $direction->egeOptional = $egeOptional; + $direction->spo = $spo; + $direction->magistracy = $magistracy; + return $direction; + }); + } +} diff --git a/app/Helpers/PositionHelper.php b/app/Helpers/PositionHelper.php new file mode 100644 index 0000000..94e9953 --- /dev/null +++ b/app/Helpers/PositionHelper.php @@ -0,0 +1,69 @@ += 254 ? 255 : $maxPosition + 1; + } + + public static function direction() + { + $maxPosition = Direction::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function educationalInstitution() + { + $maxPosition = EducationalInstitution::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function directionProfile() + { + $maxPosition = DirectionProfile::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function subjectType() + { + $maxPosition = SubjectType::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function subject() + { + $maxPosition = Subject::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function examinationType() + { + $maxPosition = ExaminationType::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function entranceExamination() + { + $maxPosition = EntranceExamination::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } + + public static function department() + { + $maxPosition = EntranceExamination::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } +} diff --git a/app/Helpers/SlugHelper.php b/app/Helpers/SlugHelper.php new file mode 100644 index 0000000..ef4c399 --- /dev/null +++ b/app/Helpers/SlugHelper.php @@ -0,0 +1,18 @@ +input()['predmets']; + $calcultatorSubjects = json_decode($getJSON); + + $filteredDirectionIds = EntranceExamination::all() + ->select("direction_id", "subject_id", "subject_type_id", "examination_type_id") + ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) + ->reduce(function (array $carry, $examine) { + + [ + 'direction_id' => $direction_id, + 'subject_id' => $subject_id, + 'subject_type_id' => $subject_type_id + ] = $examine; + + $carry[$direction_id][$subject_type_id][] = $subject_id; + $carry[$direction_id][$subject_type_id] = array_unique($carry[$direction_id][$subject_type_id]); + + return $carry; + }, []); + $directionIds = collect($filteredDirectionIds) + ->filter(function ($subjectTypes) use ($calcultatorSubjects) { + $requiredSubjects = $subjectTypes[1]; + return array_reduce($requiredSubjects, function ($acc, $requiredSubjects) use ($calcultatorSubjects) { + if (!in_array($requiredSubjects, $calcultatorSubjects)) { + return false; + } + return $acc; + }, true); + }) + ->filter(function ($subjectTypes) use ($calcultatorSubjects) { + if (array_key_exists(2, $subjectTypes)) { + $optionalSubjectsInCalculator = collect($subjectTypes[2]) + ->filter(fn($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects)); + return $optionalSubjectsInCalculator->count() !== 0; + } + return true; + }) + ->map(fn($subjectTypes, $directionId) => $directionId); + + $directions = Direction::whereIn('id', $directionIds)->get(); +// dd($directionIds); + $dataToGenerateHTML = $this->getDirectionsToModals($directionIds); +// dd($dataToGenerateHTML); + $generateHtml = function ($acc, $direction) { + $builder = new DirectonHtmlBuilderForCalculator($direction); + $offCanvasModal = $builder->getHTML(); +// dd($offCanvasModal); + return "{$acc} + + + + {$direction['name']} + + {$offCanvasModal} + + 123 + 456 + + "; + }; + $html = collect($dataToGenerateHTML)->reduce($generateHtml, ''); + + return response()->json(['html' => $html]); + } + + public function getDirectionsToModals($directionIds) + { + //phpcs:disable + $directionsGroups = Direction::with(['department']) + ->leftJoin('direction_direction_profile', 'directions.id', '=', 'direction_direction_profile.direction_id') + ->leftJoin('direction_profiles', 'direction_direction_profile.direction_profile_id', '=', 'direction_profiles.id') + ->leftJoin('departments', 'directions.department_id', '=', 'departments.id') + ->leftJoin('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->leftJoin('education_levels', 'directions.education_level_id', '=', 'education_levels.id') + ->leftJoin('education_forms', 'directions.education_form_id', '=', 'education_forms.id') + ->leftJoin('entrance_examinations', 'entrance_examinations.direction_id', '=', 'directions.id') + ->leftJoin('educational_institutions', 'faculties.educational_institution_id', '=', 'educational_institutions.id') + ->leftJoin('examination_types', 'entrance_examinations.examination_type_id', '=', 'examination_types.id') + ->leftJoin('subject_types', 'entrance_examinations.subject_type_id', '=', 'subject_types.id') + ->leftJoin('subjects', 'entrance_examinations.subject_id', '=', 'subjects.id') + ->select([ + 'directions.id as direction_id', + 'directions.code as direction_code', + 'directions.name as direction_name', + 'directions.description as direction_description', + 'directions.budget_places as direction_budget_places', + 'directions.paid_places as direction_paid_places', + 'directions.cost_paid_place as direction_cost_paid_place', + 'directions.period as direction_period', + 'education_levels.name as education_level_name', + 'education_forms.name as education_form_name', + 'faculties.id as faculty_id', + 'faculties.name as faculty_name', + 'faculties.description as faculty_description', + 'educational_institutions.id as educational_institution_id', + 'educational_institutions.name as educational_institution_name', + 'direction_profiles.id as direction_profile_id', + 'entrance_examinations.scores as entrance_examination_score', + 'examination_types.name as examination_type_name', + 'subject_types.name as subject_type_name', + 'subjects.name as subject_name', + 'direction_profiles.name as direction_profile_name', + ]) + ->whereIn('directions.id', $directionIds) + ->get()->toArray(); + //phpcs:enable + $branches = []; + $directionsGroupWithOutBranch = array_reduce($directionsGroups, function ($acc, $direction) use (&$branches) { + + if ($direction['educational_institution_id'] == 3) { + $branches[] = $direction; + } + $acc[] = $direction; + return $acc; + }, []); + + $groupedDirections = collect($directionsGroupWithOutBranch) + ->reduce(function ($carry, $item) use ($branches) { + [ + 'direction_id' => $directionId, + 'direction_name' => $directionName, + 'direction_code' => $directionCode, + 'educational_institution_id' => $educational_institution_id, + 'educational_institution_name' => $educationalInstitutionName, + 'faculty_id' => $facultyId, + 'faculty_name' => $facultyName, + 'faculty_description' => $facultyDescription, + 'education_level_name' => $educationLevelName, + 'education_form_name' => $educationFormName, + 'entrance_examination_score' => $entranceExaminationScore, + 'examination_type_name' => $examinationTypeName, + 'subject_type_name' => $subjectTypeName, + 'subject_name' => $subjectName, + 'direction_profile_name' => $directionProfileName, + 'direction_budget_places' => $directionBudgetPlaces, + 'direction_paid_places' => $directionPaidPlaces, + 'direction_cost_paid_place' => $directionCostPaidPlace, + 'direction_period' => $directionPeriod, + 'direction_description' => $directionDescription, + ] = $item; + +// $carry[$facultyName]['id'] = $facultyId; +// $carry[$facultyName]['name'] = $facultyName; +// $carry[$facultyName]['description'] = $facultyDescription; + $carry[$directionName]['name'] = $directionName; + $carry[$directionName]['id'] = $directionId; + $carry[$directionName]['code'] = $directionCode; + $carry[$directionName]['education_level'] = $educationLevelName; + $carry[$directionName]['education_form'][] = $educationFormName; + $carry[$directionName]['education_form'] = array_unique( + $carry[$directionName]['education_form'] + ); + $carry[$directionName]['entrance_examinations'] + [$examinationTypeName][$subjectTypeName][$subjectName] = $entranceExaminationScore; + $carry[$directionName]['budget_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionBudgetPlaces; + + + $carry[$directionName]['paid_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionPaidPlaces; + + /*$carry[$facultyName]['directions'][$directionName] + ['paid_places'][$educationFormName] = $directionPaidPlaces;*/ + + + $carry[$directionName] + ['cost_paid_place'][$educationFormName] = $directionCostPaidPlace; + $carry[$directionName]['period'][$educationFormName] = $directionPeriod; + $carry[$directionName]['description'] = $directionDescription; + + foreach ($branches as $branch) { + [ + 'direction_name' => $directionNameBranch, + 'educational_institution_name' => $educationalInstitutionNameBranch, + 'direction_profile_name' => $directionProfileNameBranch, + 'education_form_name' => $educationFormNameBranch, + 'direction_budget_places' => $directionBudgetPlacesBranch + ] = $branch; + if ($directionNameBranch === $directionName) { + $carry[$directionName]['budget_places'] + [$educationalInstitutionNameBranch][$directionProfileNameBranch] + [$educationFormNameBranch] = $directionBudgetPlacesBranch; + } + } + + + return $carry; + }, []); + + return $groupedDirections; + } +} diff --git a/app/Http/Controllers/Catalog/DepartmentController.php b/app/Http/Controllers/Catalog/DepartmentController.php deleted file mode 100644 index 91b1869..0000000 --- a/app/Http/Controllers/Catalog/DepartmentController.php +++ /dev/null @@ -1,75 +0,0 @@ -validated(); - - $department = new Department(); - $department->name = $validated['name']; - $department->description = $validated['description']; - $department->position = $validated['position']; - $department->faculty_id = $validated['faculty_id']; - $department->save(); - - return redirect()->route('departments.index'); - } - - public function show(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application - { - return view('catalog.department.show', compact('department')); - } - - public function edit(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application - { - $faculties = Faculty::pluck('name', 'id'); - return view('catalog.department.edit', compact('department', 'faculties')); - } - - /** - * Update the specified resource in storage. - */ - public function update(UpdateDepartmentRequest $request, Department $department) - { - $validated = $request->validated(); - - $department->name = $validated['name']; - $department->description = $validated['description']; - $department->position = $validated['position']; - $department->faculty_id = $validated['faculty_id']; - $department->save(); - - return redirect()->route('departments.index'); - } - - public function destroy(Department $department): RedirectResponse - { - $department->delete(); - return redirect()->route('departments.index'); - } -} diff --git a/app/Http/Controllers/Catalog/EducationalInstitutionController.php b/app/Http/Controllers/Catalog/EducationalInstitutionController.php deleted file mode 100644 index ebdb5fe..0000000 --- a/app/Http/Controllers/Catalog/EducationalInstitutionController.php +++ /dev/null @@ -1,70 +0,0 @@ -validated(); - - $educationalInstitution = new EducationalInstitution(); - $educationalInstitution->name = $validated['name']; - $educationalInstitution->description = $validated['description']; - $educationalInstitution->position = $validated['position']; - $educationalInstitution->save(); - - return redirect()->route('educational-institutions.index'); - } - - public function show(EducationalInstitution $educationalInstitution) - { - return view('catalog.educational-institution.show', compact('educationalInstitution')); - } - - public function edit(EducationalInstitution $educationalInstitution) - { - return view('catalog.educational-institution.edit', compact('educationalInstitution')); - } - - public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution) - { - $validated = $request->validated(); - - $educationalInstitution->name = $validated['name']; - $educationalInstitution->description = $validated['description']; - $educationalInstitution->position = $validated['position']; - $educationalInstitution->save(); - - return redirect()->route('educational-institutions.index'); - } - - public function destroy(EducationalInstitution $educationalInstitution) - { - if ($educationalInstitution->faculties()->exists()) { - return back(); - } - $educationalInstitution->delete(); - - return redirect()->route('educational-institutions.index'); - } -} diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php deleted file mode 100644 index 75ded4a..0000000 --- a/app/Http/Controllers/FileController.php +++ /dev/null @@ -1,109 +0,0 @@ -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'); - } -} diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php new file mode 100644 index 0000000..24437bb --- /dev/null +++ b/app/Http/Controllers/NewsController.php @@ -0,0 +1,61 @@ +sortDesc(); + return view('admin.news.index', compact('news')); + } + + public function create() + { + return view('admin.news.create'); + } + + public function store(StoreNewsRequest $request) + { + $validated = $request->validated(); + $urlPhoto = Storage::put('public', $request->file('photo')); + + $news = new News(); + $news->name = $validated['name']; + $news->text = $validated['text']; + $news->photo = Storage::url($urlPhoto); + $news->save(); + return redirect()->route('news.index'); + } + + public function show(News $news) + { + return view('admin.news.show', compact('news')); + } + + public function edit(News $news) + { + return view('admin.news.edit', compact('news')); + } + + public function update(UpdateNewsRequest $request, News $news) + { + $validated = $request->validated(); + + $news->name = $validated['name']; + $news->text = $validated['text']; + $news->save(); + return redirect()->route('news.index'); + } + + public function destroy(News $news) + { + $news->delete(); + return redirect()->route('news.index'); + } +} diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php deleted file mode 100644 index 59c7111..0000000 --- a/app/Http/Controllers/PageController.php +++ /dev/null @@ -1,19 +0,0 @@ -sortBy('position'); - return view('menu.reception-screen', compact('receptionScreens')); - } -} diff --git a/app/Http/Controllers/ReceptionScreenController.php b/app/Http/Controllers/ReceptionScreenController.php deleted file mode 100644 index a402db0..0000000 --- a/app/Http/Controllers/ReceptionScreenController.php +++ /dev/null @@ -1,82 +0,0 @@ -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'); - } -} diff --git a/app/Http/Controllers/admin/AdmissionController.php b/app/Http/Controllers/admin/AdmissionController.php new file mode 100644 index 0000000..a19f69a --- /dev/null +++ b/app/Http/Controllers/admin/AdmissionController.php @@ -0,0 +1,72 @@ +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'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/DepartmentController.php b/app/Http/Controllers/admin/Catalog/DepartmentController.php new file mode 100644 index 0000000..8db3abf --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/DepartmentController.php @@ -0,0 +1,121 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $department = new Department(); + $department->name = $validated['name']; + $department->description = $validated['description']; + $department->position = $validated['position']; + $department->faculty_id = $validated['faculty_id']; + $department->slug = $slug; + $department->save(); + + Log::channel('app') + ->info( + 'CREATE кафедра {department} - user {user}', + ['user' => Auth::user()->name, 'department' => $department->name, 'data' => $validated] + ); + + 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(); + $oldData = $department->toArray(); + + $department->name = $validated['name']; + $department->description = $validated['description']; + $department->position = $validated['position']; + $department->faculty_id = $validated['faculty_id']; + $department->slug = $validated['slug']; + + Log::channel('app') + ->warning( + 'UPDATE кафедра {department} - user {user}', + [ + 'user' => Auth::user()->name, + 'department' => $department->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $department->save(); + + return redirect()->route('departments.index'); + } + + public function destroy(Department $department): RedirectResponse + { + if ($department->directions()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE кафедра {department} - user {user}', + [ + 'user' => Auth::user()->name, + 'department' => $department->name, + 'data' => $department->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE кафедра {department} - user {user}', + [ + 'user' => Auth::user()->name, + 'department' => $department->name, + 'data' => $department->toArray(), + ] + ); + $department->delete(); + return redirect()->route('departments.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/DirectionProfileController.php b/app/Http/Controllers/admin/Catalog/Direction/DirectionProfileController.php new file mode 100644 index 0000000..66b9019 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/DirectionProfileController.php @@ -0,0 +1,118 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $directionProfile = new DirectionProfile(); + $directionProfile->name = $validated['name']; + $directionProfile->description = $validated['description']; + $directionProfile->slug = $slug; + $directionProfile->position = $validated['position']; + $directionProfile->save(); + + Log::channel('app') + ->info( + 'CREATE профиль подготовки {directionProfile} - user {user}', + ['user' => Auth::user()->name, 'directionProfile' => $directionProfile->name, 'data' => $validated] + ); + + return redirect()->route('direction_profiles.index'); + } + + public function show(DirectionProfile $directionProfile): View + { + return view('admin.catalog.direction.direction_profile.show', compact('directionProfile')); + } + + public function edit(DirectionProfile $directionProfile): View + { + $directions = Direction::pluck('name', 'id'); + return view( + 'admin.catalog.direction.direction_profile.edit', + compact('directionProfile', 'directions') + ); + } + + public function update(UpdateDirectionProfileRequest $request, DirectionProfile $directionProfile): RedirectResponse + { + $validated = $request->validated(); + $oldData = $directionProfile->toArray(); + + $directionProfile->name = $validated['name']; + $directionProfile->description = $validated['description']; + $directionProfile->slug = $validated['slug']; + $directionProfile->position = $validated['position']; + $directionProfile->save(); + + Log::channel('app') + ->warning( + 'UPDATE профиль подготовки {directionProfile} - user {user}', + [ + 'user' => Auth::user()->name, + 'directionProfile' => $directionProfile->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + return redirect()->route('direction_profiles.index'); + } + + public function destroy(DirectionProfile $directionProfile): RedirectResponse + { + if ($directionProfile->direction()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE профиль подготовки {directionProfile} - user {user}', + [ + 'user' => Auth::user()->name, + 'directionProfile' => $directionProfile->name, + 'data' => $directionProfile->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE профиль подготовки {directionProfile} - user {user}', + [ + 'user' => Auth::user()->name, + 'directionProfile' => $directionProfile->name, + 'data' => $directionProfile->toArray(), + ] + ); + $directionProfile->delete(); + return redirect()->route('direction_profiles.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/EducationFormController.php b/app/Http/Controllers/admin/Catalog/Direction/EducationFormController.php new file mode 100644 index 0000000..1572bb6 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/EducationFormController.php @@ -0,0 +1,111 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $form = new EducationForm(); + $form->name = $validated['name']; + $form->description = $validated['description']; + $form->slug = $slug; + $form->save(); + + Log::channel('app') + ->info( + 'CREATE форма образования {educationForm} - user {user}', + ['user' => Auth::user()->name, 'educationForm' => $form->name, 'data' => $validated] + ); + return redirect()->route('education_forms.index'); + } + + public function show(EducationForm $educationForm): View|Factory|\Illuminate\Contracts\Foundation\Application + { + $directions = $educationForm->directions; + return view('admin.catalog.direction.education_form.show', compact('educationForm', 'directions')); + } + + public function edit(EducationForm $educationForm) + { + return view('admin.catalog.direction.education_form.edit', compact('educationForm')); + } + + public function update(UpdateEducationFormRequest $request, EducationForm $educationForm) + { + $validated = $request->validated(); + $oldData = $educationForm->toArray(); + + $educationForm->name = $validated['name']; + $educationForm->description = $validated['description']; + $educationForm->slug = $validated['slug']; + + Log::channel('app') + ->warning( + 'UPDATE форма образования {educationForm} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationForm' => $educationForm->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $educationForm->save(); + + return redirect()->route('education_forms.index'); + } + + public function destroy(EducationForm $educationForm) + { + if ($educationForm->directions()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE форма образования {educationForm} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationForm' => $educationForm->name, + 'data' => $educationForm->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE факультет {faculty} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationForm' => $educationForm->name, + 'data' => $educationForm->toArray(), + ] + ); + $educationForm->delete(); + return redirect()->route('education_forms.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/EducationLevelController.php b/app/Http/Controllers/admin/Catalog/Direction/EducationLevelController.php new file mode 100644 index 0000000..ccfabee --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/EducationLevelController.php @@ -0,0 +1,114 @@ +validated(); + $slug = SlugHelper::get($validated); + + $level = new EducationLevel(); + $level->name = $validated['name']; + $level->description = $validated['description']; + $level->slug = $slug; + $level->save(); + + Log::channel('app') + ->info( + 'CREATE уровень образования {educationLevel} - user {user}', + ['user' => Auth::user()->name, 'educationLevel' => $level->name, 'data' => $validated] + ); + + return redirect()->route('education_levels.index'); + } + + public function show(EducationLevel $educationLevel): View + { + $directions = $educationLevel->directions(); + return view( + 'admin.catalog.direction.education_level.show', + compact('educationLevel', 'directions') + ); + } + + public function edit(EducationLevel $educationLevel) + { + return view('admin.catalog.direction.education_level.edit', compact('educationLevel')); + } + + public function update(UpdateEducationLevelRequest $request, EducationLevel $educationLevel): RedirectResponse + { + $validated = $request->validated(); + $oldData = $educationLevel->toArray(); + + $educationLevel->name = $validated['name']; + $educationLevel->description = $validated['description']; + $educationLevel->slug = $validated['slug']; + + Log::channel('app') + ->warning( + 'UPDATE уровень образования {educationLevel} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationLevel' => $educationLevel->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + $educationLevel->save(); + + return redirect()->route('education_levels.index'); + } + + public function destroy(EducationLevel $educationLevel) + { + if ($educationLevel->directions()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE уровень образования {educationLevel} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationLevel' => $educationLevel->name, + 'data' => $educationLevel->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE уровень образования {educationLevel} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationLevel' => $educationLevel->name, + 'data' => $educationLevel->toArray(), + ] + ); + $educationLevel->delete(); + return redirect()->route('education_levels.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php new file mode 100644 index 0000000..ae739e6 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php @@ -0,0 +1,139 @@ +validated(); + + $entranceExamination = new EntranceExamination(); + $entranceExamination->examination_type_id = $validated['examination_type_id']; + $entranceExamination->direction_id = $validated['direction_id']; + $entranceExamination->subject_id = $validated['subject_id']; + $entranceExamination->scores = $validated['scores']; + $entranceExamination->position = $validated['position']; + $entranceExamination->subject_type_id = $validated['subject_type_id']; + $entranceExamination->save(); + + + Log::channel('app') + ->info( + 'CREATE вступ. испытания {entranceExamination} - user {user}', + [ + 'user' => Auth::user()->name, + 'entranceExamination' => $entranceExamination->name, + 'data' => $validated + ] + ); + + return redirect()->route('entrance_examinations.index'); + } + + public function show(EntranceExamination $entranceExamination): View + { + return view( + 'admin.catalog.direction.entrance_examination.show', + compact('entranceExamination') + ); + } + + public function edit(EntranceExamination $entranceExamination): View + { + $directions = Direction::pluck('full_name', 'id'); + $examination_types = ExaminationType::pluck('name', 'id'); + $subjects = Subject::pluck('name', 'id'); + $subjectTypes = SubjectType::pluck('name', 'id'); + return view( + 'admin.catalog.direction.entrance_examination.edit', + compact( + 'entranceExamination', + 'directions', + 'examination_types', + 'subjects', + 'subjectTypes', + ) + ); + } + + public function update( + UpdateEntranceExaminationRequest $request, + EntranceExamination $entranceExamination + ): RedirectResponse { + $validated = $request->validated(); + $oldData = $entranceExamination->toArray(); + + $entranceExamination->examination_type_id = $validated['examination_type_id']; + $entranceExamination->direction_id = $validated['direction_id']; + $entranceExamination->subject_id = $validated['subject_id']; + $entranceExamination->scores = $validated['scores']; + $entranceExamination->position = $validated['position']; + $entranceExamination->subject_type_id = $validated['subject_type_id']; + + Log::channel('app') + ->warning( + 'UPDATE вступ. испытания {entranceExamination} - user {user}', + [ + 'user' => Auth::user()->name, + 'entranceExamination' => $entranceExamination->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + $entranceExamination->save(); + + return redirect()->route('entrance_examinations.index'); + } + + public function destroy(EntranceExamination $entranceExamination): RedirectResponse + { + Log::channel('app') + ->critical( + 'DELETE вступ. испытания {entranceExamination} - user {user}', + [ + 'user' => Auth::user()->name, + 'entranceExamination' => $entranceExamination->name, + 'data' => $entranceExamination->toArray(), + ] + ); + $entranceExamination->delete(); + return redirect()->route('entrance_examinations.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php b/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php new file mode 100644 index 0000000..db98788 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/ExaminationTypeController.php @@ -0,0 +1,112 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $type = new ExaminationType(); + $type->name = $validated['name']; + $type->description = $validated['description']; + $type->slug = $slug; + $type->position = $validated['position']; + $type->save(); + + Log::channel('app') + ->info( + 'CREATE тип экзамена {examinationType} - user {user}', + ['user' => Auth::user()->name, 'faculty' => $type->name, 'data' => $validated] + ); + + return redirect()->route('examination_types.index'); + } + + public function show(ExaminationType $examinationType): View + { + return view('admin.catalog.direction.examination_type.show', compact('examinationType')); + } + + public function edit(ExaminationType $examinationType): View + { + return view('admin.catalog.direction.examination_type.edit', compact('examinationType')); + } + + public function update(UpdateExaminationTypeRequest $request, ExaminationType $examinationType): RedirectResponse + { + $validated = $request->validated(); + $oldData = $examinationType->toArray(); + + $examinationType->name = $validated['name']; + $examinationType->description = $validated['description']; + $examinationType->slug = $validated['slug']; + $examinationType->position = $validated['position']; + + Log::channel('app') + ->warning( + 'UPDATE тип экзамена {examinationType} - user {user}', + [ + 'user' => Auth::user()->name, + 'examinationType' => $examinationType->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $examinationType->save(); + return redirect()->route('examination_types.index'); + } + + public function destroy(ExaminationType $examinationType): RedirectResponse + { + if ($examinationType->entranceExaminations()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE тип экзамена {examinationType} - user {user}', + [ + 'user' => Auth::user()->name, + 'examinationType' => $examinationType->name, + 'data' => $examinationType->toArray(), + ] + ); + return back(); + } + + Log::channel('app') + ->critical( + 'DELETE тип экзамена {examinationType} - user {user}', + [ + 'user' => Auth::user()->name, + 'examinationType' => $examinationType->name, + 'data' => $examinationType->toArray(), + ] + ); + $examinationType->delete(); + return redirect()->route('examination_types.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/SubjectController.php b/app/Http/Controllers/admin/Catalog/Direction/SubjectController.php new file mode 100644 index 0000000..10c493b --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/SubjectController.php @@ -0,0 +1,111 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $subject = new Subject(); + $subject->name = $validated['name']; + $subject->description = $validated['description']; + $subject->slug = $slug; + $subject->position = $validated['position']; + $subject->save(); + + Log::channel('app') + ->info( + 'CREATE предмет {subject} - user {user}', + ['user' => Auth::user()->name, 'faculty' => $subject->name, 'data' => $validated] + ); + + return redirect()->route('subjects.index'); + } + + public function show(Subject $subject): View + { + return view('admin.catalog.direction.subject.show', compact('subject')); + } + + public function edit(Subject $subject): View + { + return view('admin.catalog.direction.subject.edit', compact('subject')); + } + + public function update(UpdateSubjectRequest $request, Subject $subject): RedirectResponse + { + $validated = $request->validated(); + $oldData = $subject->toArray(); + + $subject->name = $validated['name']; + $subject->description = $validated['description']; + $subject->slug = $validated['slug']; + $subject->position = $validated['position']; + + Log::channel('app') + ->warning( + 'UPDATE предмет {subject} - user {user}', + [ + 'user' => Auth::user()->name, + 'subject' => $subject->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $subject->save(); + return redirect()->route('subjects.index'); + } + + public function destroy(Subject $subject): RedirectResponse + { + if ($subject->entranceExaminations()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE предмет {subject} - user {user}', + [ + 'user' => Auth::user()->name, + 'subject' => $subject->name, + 'data' => $subject->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE предмет {subject} - user {user}', + [ + 'user' => Auth::user()->name, + 'subject' => $subject->name, + 'data' => $subject->toArray(), + ] + ); + $subject->delete(); + return redirect()->route('subjects.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/Direction/SubjectTypeController.php b/app/Http/Controllers/admin/Catalog/Direction/SubjectTypeController.php new file mode 100644 index 0000000..f3989eb --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/SubjectTypeController.php @@ -0,0 +1,112 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $type = new SubjectType(); + $type->name = $validated['name']; + $type->description = $validated['description']; + $type->slug = $slug; + $type->position = $validated['position']; + $type->save(); + + Log::channel('app') + ->info( + 'CREATE тип предмета {subjectType} - user {user}', + ['user' => Auth::user()->name, 'subjectType' => $type->name, 'data' => $validated] + ); + + return redirect()->route('subject_types.index'); + } + + public function show(SubjectType $subjectType): View + { + return view('admin.catalog.direction.subject_type.show', compact('subjectType')); + } + + public function edit(SubjectType $subjectType): View + { + return view('admin.catalog.direction.subject_type.edit', compact('subjectType')); + } + + public function update(UpdateSubjectTypeRequest $request, SubjectType $subjectType): RedirectResponse + { + $validated = $request->validated(); + $oldData = $subjectType->toArray(); + + $subjectType->name = $validated['name']; + $subjectType->description = $validated['description']; + $subjectType->slug = $validated['slug']; + $subjectType->position = $validated['position']; + $subjectType->save(); + + Log::channel('app') + ->warning( + 'UPDATE тип предмета {subjectType} - user {user}', + [ + 'user' => Auth::user()->name, + 'subjectType' => $subjectType->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + return redirect()->route('subject_types.index'); + } + + public function destroy(SubjectType $subjectType): RedirectResponse + { + if ($subjectType->entranceExaminations()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE тип предмета {subjectType} - user {user}', + [ + 'user' => Auth::user()->name, + 'subjectType' => $subjectType->name, + 'data' => $subjectType->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE тип предмета {subjectType} - user {user}', + [ + 'user' => Auth::user()->name, + 'subjectType' => $subjectType->name, + 'data' => $subjectType->toArray(), + ] + ); + $subjectType->delete(); + return redirect()->route('subject_types.index'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/DirectionController.php b/app/Http/Controllers/admin/Catalog/DirectionController.php new file mode 100644 index 0000000..1c1fe6a --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/DirectionController.php @@ -0,0 +1,319 @@ +allowedFilters('name') + ->orderBy('id', 'desc')->get(); +// $directions = Direction::all()->sortBy('created_at', SORT_REGULAR, true); + $filter = $request->filter ?? null; + return view('admin.catalog.direction.index', compact('directions', 'filter')); + } + + public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application + { + $levels = EducationLevel::pluck('name', 'id'); + $forms = EducationForm::pluck('name', 'id'); + $departments = Department::all() + ->reduce(function (?array $carry, $department) { + $carry[$department->id] = "{$department->name} - {$department->faculty->name}"; + return $carry; + }); + $examination_types = ExaminationType::pluck('name', 'id'); + $subjects = Subject::pluck('name', 'id'); + $subjectTypes = SubjectType::pluck('name', 'id'); + $directionProfiles = DirectionProfile::pluck('name', 'id'); + return view( + 'admin.catalog.direction.create', + compact( + 'departments', + 'levels', + 'forms', + 'examination_types', + 'subjectTypes', + 'subjects', + 'directionProfiles', + ) + ); + } + + public function store(StoreDirectionRequest $request): RedirectResponse + { + + $validated = $request->validated(); + $slug = SlugHelper::get($validated); + + $direction = new Direction(); + $direction->name = $validated['name']; + $direction->full_name = "{$validated['code']} {$validated['name']}"; + $direction->description = $validated['description']; + $direction->position = $validated['position']; + $direction->slug = $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->budget_places = $validated['budget_places']; + $direction->quota = $validated['quota']; + $direction->paid_places = $validated['paid_places']; + $direction->cost_paid_place = $validated['cost_paid_place']; + $direction->period = $validated['period']; + $direction->save(); + + if (array_key_exists('entrance-examination', $validated)) { + foreach ($validated['entrance-examination'] as $data) { + $entranceExamination = new EntranceExamination(); + $entranceExamination->examination_type_id = $data['examination_type_id']; + $entranceExamination->direction_id = $direction->id; + $entranceExamination->subject_id = $data['subject_id']; + $entranceExamination->scores = $data['scores']; + $entranceExamination->position = $data['position']; + $entranceExamination->subject_type_id = $data['subject_type_id']; + $entranceExamination->save(); + } + } + + + + if (array_key_exists('direction_profiles', $validated)) { + $direction->directionProfiles()->attach($validated['direction_profiles']); + } + + Log::channel('app') + ->info( + 'CREATE напр. подготовки {direction} - user {user}', + [ + 'user' => Auth::user()->name, + 'direction' => $direction->name, + 'data' => $validated + ] + ); + 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; + + $ege = $direction + ->entranceExaminations + ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) + ->sortBy('position') + ->pluck('scores', 'subject_id'); + + $spo = $direction + ->entranceExaminations->where('examination_type_id', '=', ExaminationTypeEnum::Spo->value) + ->sortBy('position') + ->pluck('scores', 'subject_id'); + + $magistracy = $direction + ->entranceExaminations + ->where('examination_type_id', '=', ExaminationTypeEnum::Magistracy->value) + ->sortBy('position') + ->pluck('scores', 'subject_id'); + + return view( + 'admin.catalog.direction.show', + compact( + 'direction', + 'educationalInstitution', + 'faculty', + 'department', + 'ege', + 'spo', + 'magistracy', + ) + ); + } + + public function edit(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application + { + $levels = EducationLevel::pluck('name', 'id'); + $forms = EducationForm::pluck('name', 'id'); + $departments = Department::all() + ->reduce(function (?array $carry, $department) { + $carry[$department->id] = "{$department->name} - {$department->faculty->name}"; + return $carry; + }); + $examination_types = ExaminationType::pluck('name', 'id'); + $subjects = Subject::pluck('name', 'id'); + $subjectTypes = SubjectType::pluck('name', 'id'); + $directionProfiles = DirectionProfile::pluck('name', 'id'); + return view( + 'admin.catalog.direction.edit', + compact( + 'direction', + 'departments', + 'levels', + 'forms', + 'examination_types', + 'subjectTypes', + 'subjects', + 'directionProfiles', + ) + ); + } + + public function update(UpdateDirectionRequest $request, Direction $direction): RedirectResponse + { + $oldData = $direction->toArray(); + $validated = $request->validated(); + + $direction->name = $validated['name']; + $direction->full_name = "{$validated['code']} {$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->budget_places = $validated['budget_places']; + $direction->quota = $validated['quota']; + $direction->paid_places = $validated['paid_places']; + $direction->cost_paid_place = $validated['cost_paid_place']; + $direction->period = $validated['period']; + + Log::channel('app') + ->warning( + 'UPDATE напр. подготовки {direction} - user {user}', + [ + 'user' => Auth::user()->name, + 'direction' => $direction->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $direction->save(); + + if (array_key_exists('entrance-examination', $validated)) { + foreach ($validated['entrance-examination'] as $id => $data) { + $entranceExamination = EntranceExamination::firstOrNew(['id' => $id]); + $entranceExamination->direction_id = $direction->id; + $entranceExamination->subject_id = $data['subject_id']; + $entranceExamination->scores = $data['scores']; + $entranceExamination->position = $data['position']; + $entranceExamination->subject_type_id = $data['subject_type_id']; + $entranceExamination->examination_type_id = $data['examination_type_id']; + $entranceExamination->save(); + } + } + + + if (array_key_exists('delete', $validated)) { + foreach ($validated['delete'] as $id => $value) { + $entranceExamination = EntranceExamination::firstOrNew(['id' => $id]); + $entranceExamination->delete(); + } + } + + + if (array_key_exists('direction_profiles', $validated)) { + $direction->directionProfiles()->sync($validated['direction_profiles']); + } + + return redirect()->route('directions.index'); + } + + public function destroy(Direction $direction): RedirectResponse + { + $direction->entranceExaminations()->each(fn ($entranceExamination) => $entranceExamination->delete()); + $direction->directionProfiles()->detach(); + $direction->delete(); + Log::channel('app') + ->critical( + 'DELETE напр. подготовки {direction} - user {user}', + [ + 'user' => Auth::user()->name, + 'direction' => $direction->name, + 'data' => $direction->toArray(), + ] + ); + return redirect()->route('directions.index'); + } + + public function duplication(Direction $direction): RedirectResponse + { + $now = now()->toAtomString(); + $newDirection = new Direction(); + $newDirection->name = $direction->name; + $newDirection->full_name = "{$direction->code} {$direction->name}"; + $newDirection->description = $direction->description; + $newDirection->position = $direction->position; + $newDirection->slug = "{$direction->slug} {$now}"; + $newDirection->code = $direction->code; + $newDirection->education_level_id = $direction->education_level_id; + $newDirection->education_form_id = $direction->education_form_id; + $newDirection->department_id = $direction->department_id; + $newDirection->budget_places = $direction->budget_places; + $newDirection->quota = $direction->quota; + $newDirection->paid_places = $direction->paid_places; + $newDirection->cost_paid_place = $direction->cost_paid_place; + $newDirection->period = $direction->period; + $newDirection->save(); + + + foreach ($direction->entranceExaminations as $entranceExamination) { + $newEntranceExamination = new EntranceExamination(); + $newEntranceExamination->examination_type_id = $entranceExamination->examination_type_id; + $newEntranceExamination->direction_id = $newDirection->id; + $newEntranceExamination->subject_id = $entranceExamination->subject_id; + $newEntranceExamination->scores = $entranceExamination->scores; + $newEntranceExamination->position = $entranceExamination->position; + $newEntranceExamination->subject_type_id = $entranceExamination->subject_type_id; + $newEntranceExamination->save(); + } + + $newDirection->directionProfiles()->attach($direction->directionProfiles); + + Log::channel('app') + ->info( + 'DUPLICATE напр. подготовки {direction} - user {user}', + [ + 'user' => Auth::user()->name, + 'direction' => $direction->name, + 'data' => $direction->toArray(), + ] + ); + + return redirect()->route('directions.index'); + } + + public function exportXls() + { + return Excel::download(new DirectionsExport(), 'directions.xlsx'); + } +} diff --git a/app/Http/Controllers/admin/Catalog/EducationalInstitutionController.php b/app/Http/Controllers/admin/Catalog/EducationalInstitutionController.php new file mode 100644 index 0000000..99ae276 --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/EducationalInstitutionController.php @@ -0,0 +1,118 @@ +validated(); + + $slug = SlugHelper::get($validated); + + $educationalInstitution = new EducationalInstitution(); + $educationalInstitution->name = $validated['name']; + $educationalInstitution->description = $validated['description']; + $educationalInstitution->slug = $slug; + $educationalInstitution->position = $validated['position']; + $educationalInstitution->save(); + + Log::channel('app') + ->info( + 'CREATE учеб. заведение {educationalInstitution} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationalInstitution' => $educationalInstitution->name, + 'data' => $validated + ] + ); + + return redirect()->route('educational_institutions.index'); + } + + public function show(EducationalInstitution $educationalInstitution) + { + return view('admin.catalog.educational_institution.show', compact('educationalInstitution')); + } + + public function edit(EducationalInstitution $educationalInstitution) + { + return view('admin.catalog.educational_institution.edit', compact('educationalInstitution')); + } + + public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution) + { + $validated = $request->validated(); + $oldData = $educationalInstitution->toArray(); + + $educationalInstitution->name = $validated['name']; + $educationalInstitution->description = $validated['description']; + $educationalInstitution->position = $validated['position']; + $educationalInstitution->slug = $validated['slug']; + + Log::channel('app') + ->warning( + 'UPDATE учеб. заведение {educationalInstitution} - user {user}', + [ + 'user' => Auth::user()->name, + 'faculty' => $educationalInstitution->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $educationalInstitution->save(); + + return redirect()->route('educational_institutions.index'); + } + + public function destroy(EducationalInstitution $educationalInstitution) + { + if ($educationalInstitution->faculties()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE учеб. заведение {educationalInstitution} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationalInstitution' => $educationalInstitution->name, + 'data' => $educationalInstitution->toArray(), + ] + ); + return back(); + } + Log::channel('app') + ->critical( + 'DELETE учеб. заведение {educationalInstitution} - user {user}', + [ + 'user' => Auth::user()->name, + 'educationalInstitution' => $educationalInstitution->name, + 'data' => $educationalInstitution->toArray(), + ] + ); + $educationalInstitution->delete(); + + return redirect()->route('educational_institutions.index'); + } +} diff --git a/app/Http/Controllers/Catalog/FacultyController.php b/app/Http/Controllers/admin/Catalog/FacultyController.php similarity index 51% rename from app/Http/Controllers/Catalog/FacultyController.php rename to app/Http/Controllers/admin/Catalog/FacultyController.php index f32476d..4b27cef 100644 --- a/app/Http/Controllers/Catalog/FacultyController.php +++ b/app/Http/Controllers/admin/Catalog/FacultyController.php @@ -1,75 +1,118 @@ validated(); + $slug = SlugHelper::get($validated); + $faculty = new Faculty(); $faculty->name = $validated['name']; $faculty->description = $validated['description']; $faculty->position = $validated['position']; + $faculty->slug = $slug; $faculty->educational_institution_id = $validated['educational_institution_id']; $faculty->save(); + Log::channel('app') + ->info( + 'CREATE факультет {faculty} - user {user}', + ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated] + ); + return redirect()->route('faculties.index'); } public function show(Faculty $faculty): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { - return view('catalog.faculty.show', compact('faculty')); + 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('catalog.faculty.edit', compact('faculty', 'educationalInstitutions')); + return view('admin.catalog.faculty.edit', compact('faculty', 'educationalInstitutions')); } public function update(UpdateFacultyRequest $request, Faculty $faculty): RedirectResponse { $validated = $request->validated(); + $oldData = $faculty->toArray(); $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(); + Log::channel('app') + ->warning( + 'UPDATE факультет {faculty} - user {user}', + [ + 'user' => Auth::user()->name, + 'faculty' => $faculty->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); + + $faculty->save(); return redirect()->route('faculties.index'); } public function destroy(Faculty $faculty): RedirectResponse { if ($faculty->departments()->exists()) { + Log::channel('app') + ->error( + 'NOT DELETE факультет {faculty} - user {user}', + [ + 'user' => Auth::user()->name, + 'faculty' => $faculty->name, + 'data' => $faculty->toArray(), + ] + ); return back(); } + Log::channel('app') + ->critical( + 'DELETE факультет {faculty} - user {user}', + [ + 'user' => Auth::user()->name, + 'faculty' => $faculty->name, + 'data' => $faculty->toArray(), + ] + ); $faculty->delete(); return redirect()->route('faculties.index'); } diff --git a/app/Http/Controllers/admin/DocumentController.php b/app/Http/Controllers/admin/DocumentController.php new file mode 100644 index 0000000..be85d94 --- /dev/null +++ b/app/Http/Controllers/admin/DocumentController.php @@ -0,0 +1,99 @@ +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(); + } +} diff --git a/app/Http/Controllers/admin/PageController.php b/app/Http/Controllers/admin/PageController.php new file mode 100644 index 0000000..8441b28 --- /dev/null +++ b/app/Http/Controllers/admin/PageController.php @@ -0,0 +1,507 @@ +sortBy('position'); +// return view('menu.reception-screen', compact('admissions')); +// } + + public function bakalavr() + { + $news = News::all(); + $admissions = Admission::all(); + $faculties = Faculty::all(); + $subjects = EntranceExamination::all() + ->select('subject_id', 'subject_type_id', 'examination_type_id') + ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) + ->reduce(function (?array $carry, $subject) { + $id = $subject['subject_id']; + $value = Subject::find($id)->name; + $carry[$id] = $value; + return $carry; + }); + $directionsWithInstitution = Direction::with(['department']) + ->join('departments', 'directions.department_id', '=', 'departments.id') + ->join('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->join( + 'educational_institutions', + 'faculties.educational_institution_id', + '=', + 'educational_institutions.id' + ) + ->get([ + 'directions.id', + 'directions.name', + "educational_institutions.name as educational_institution_name" + ]); + //phpcs:disable + $directionsGroups = Direction::with(['department']) + ->leftJoin('direction_direction_profile', 'directions.id', '=', 'direction_direction_profile.direction_id') + ->leftJoin('direction_profiles','direction_direction_profile.direction_profile_id','=','direction_profiles.id') + ->leftJoin('departments', 'directions.department_id', '=', 'departments.id') + ->leftJoin('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->leftJoin('education_levels', 'directions.education_level_id', '=', 'education_levels.id') + ->leftJoin('education_forms', 'directions.education_form_id', '=', 'education_forms.id') + ->leftJoin('entrance_examinations', 'entrance_examinations.direction_id', '=', 'directions.id') + ->leftJoin('educational_institutions','faculties.educational_institution_id','=','educational_institutions.id') + ->leftJoin('examination_types', 'entrance_examinations.examination_type_id', '=', 'examination_types.id') + ->leftJoin('subject_types', 'entrance_examinations.subject_type_id', '=', 'subject_types.id') + ->leftJoin('subjects', 'entrance_examinations.subject_id', '=', 'subjects.id') + ->select( + 'directions.id as direction_id', + 'directions.code as direction_code', + 'directions.name as direction_name', + 'directions.description as direction_description', + 'directions.budget_places as direction_budget_places', + 'directions.paid_places as direction_paid_places', + 'directions.cost_paid_place as direction_cost_paid_place', + 'directions.period as direction_period', + 'education_levels.name as education_level_name', + 'education_forms.name as education_form_name', + 'faculties.id as faculty_id', + 'faculties.name as faculty_name', + 'faculties.description as faculty_description', + 'educational_institutions.id as educational_institution_id', + 'educational_institutions.name as educational_institution_name', + 'direction_profiles.id as direction_profile_id', + 'entrance_examinations.scores as entrance_examination_score', + 'examination_types.name as examination_type_name', + 'subject_types.name as subject_type_name', + 'subjects.name as subject_name', + 'direction_profiles.name as direction_profile_name', + ) + ->get()->toArray(); + //phpcs:enable + $branches = []; + $directionsGroupWithOutBranch = array_reduce($directionsGroups, function ($acc, $direction) use (&$branches) { + + if ($direction['educational_institution_id'] == 3) { + $branches[] = $direction; + } + $acc[] = $direction; + return $acc; + }, []); + + $groupedDirections = collect($directionsGroupWithOutBranch) + ->reduce(function ($carry, $item, $key) use ($branches) { + [ + 'direction_id' => $directionId, + 'direction_name' => $directionName, + 'direction_code' => $directionCode, + 'educational_institution_id' => $educational_institution_id, + 'educational_institution_name' => $educationalInstitutionName, + 'faculty_id' => $facultyId, + 'faculty_name' => $facultyName, + 'faculty_description' => $facultyDescription, + 'education_level_name' => $educationLevelName, + 'education_form_name' => $educationFormName, + 'entrance_examination_score' => $entranceExaminationScore, + 'examination_type_name' => $examinationTypeName, + 'subject_type_name' => $subjectTypeName, + 'subject_name' => $subjectName, + 'direction_profile_name' => $directionProfileName, + 'direction_budget_places' => $directionBudgetPlaces, + 'direction_paid_places' => $directionPaidPlaces, + 'direction_cost_paid_place' => $directionCostPaidPlace, + 'direction_period' => $directionPeriod, + 'direction_description' => $directionDescription, + ] = $item; + + $carry[$facultyName]['id'] = $facultyId; + $carry[$facultyName]['name'] = $facultyName; + $carry[$facultyName]['description'] = $facultyDescription; + $carry[$facultyName]['directions'][$directionName]['name'] = $directionName; + $carry[$facultyName]['directions'][$directionName]['id'] = $directionId; + $carry[$facultyName]['directions'][$directionName]['code'] = $directionCode; + $carry[$facultyName]['directions'][$directionName]['education_level'] = $educationLevelName; + $carry[$facultyName]['directions'][$directionName]['education_form'][] = $educationFormName; + $carry[$facultyName]['directions'][$directionName]['education_form'] = array_unique( + $carry[$facultyName]['directions'][$directionName]['education_form'] + ); + $carry[$facultyName]['directions'][$directionName]['entrance_examinations'] + [$examinationTypeName][$subjectTypeName][$subjectName] = $entranceExaminationScore; + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionBudgetPlaces; + + + $carry[$facultyName]['directions'][$directionName]['paid_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionPaidPlaces; + + /*$carry[$facultyName]['directions'][$directionName] + ['paid_places'][$educationFormName] = $directionPaidPlaces;*/ + + + $carry[$facultyName]['directions'][$directionName] + ['cost_paid_place'][$educationFormName] = $directionCostPaidPlace; + $carry[$facultyName]['directions'][$directionName]['period'][$educationFormName] = $directionPeriod; + $carry[$facultyName]['directions'][$directionName]['description'] = $directionDescription; + + foreach ($branches as $branch) { + [ + 'direction_name' => $directionNameBranch, + 'educational_institution_name' => $educationalInstitutionNameBranch, + 'direction_profile_name' => $directionProfileNameBranch, + 'education_form_name' => $educationFormNameBranch, + 'direction_budget_places' => $directionBudgetPlacesBranch + ] = $branch; + if ($directionNameBranch === $directionName) { + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionNameBranch][$directionProfileNameBranch] + [$educationFormNameBranch] = $directionBudgetPlacesBranch; + } + } + + + return $carry; + }, []); + + return view('new-design.bakalavr-special', compact( + 'faculties', + 'subjects', + 'directionsWithInstitution', + 'groupedDirections', + 'admissions', + 'news', + )); + } + public function inostran() + { + $news = News::all(); + $admissions = Admission::all(); + $faculties = Faculty::all(); + $subjects = EntranceExamination::all() + ->select('subject_id', 'subject_type_id', 'examination_type_id') + ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) + ->reduce(function (?array $carry, $subject) { + $id = $subject['subject_id']; + $value = Subject::find($id)->name; + $carry[$id] = $value; + return $carry; + }); + $directionsWithInstitution = Direction::with(['department']) + ->join('departments', 'directions.department_id', '=', 'departments.id') + ->join('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->join( + 'educational_institutions', + 'faculties.educational_institution_id', + '=', + 'educational_institutions.id' + ) + ->get([ + 'directions.id', + 'directions.name', + "educational_institutions.name as educational_institution_name" + ]); + //phpcs:disable + $directionsGroups = Direction::with(['department']) + ->leftJoin('direction_direction_profile', 'directions.id', '=', 'direction_direction_profile.direction_id') + ->leftJoin('direction_profiles','direction_direction_profile.direction_profile_id','=','direction_profiles.id') + ->leftJoin('departments', 'directions.department_id', '=', 'departments.id') + ->leftJoin('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->leftJoin('education_levels', 'directions.education_level_id', '=', 'education_levels.id') + ->leftJoin('education_forms', 'directions.education_form_id', '=', 'education_forms.id') + ->leftJoin('entrance_examinations', 'entrance_examinations.direction_id', '=', 'directions.id') + ->leftJoin('educational_institutions','faculties.educational_institution_id','=','educational_institutions.id') + ->leftJoin('examination_types', 'entrance_examinations.examination_type_id', '=', 'examination_types.id') + ->leftJoin('subject_types', 'entrance_examinations.subject_type_id', '=', 'subject_types.id') + ->leftJoin('subjects', 'entrance_examinations.subject_id', '=', 'subjects.id') + ->select( + 'directions.id as direction_id', + 'directions.code as direction_code', + 'directions.name as direction_name', + 'directions.description as direction_description', + 'directions.budget_places as direction_budget_places', + 'directions.paid_places as direction_paid_places', + 'directions.cost_paid_place as direction_cost_paid_place', + 'directions.period as direction_period', + 'education_levels.name as education_level_name', + 'education_forms.name as education_form_name', + 'faculties.id as faculty_id', + 'faculties.name as faculty_name', + 'faculties.description as faculty_description', + 'educational_institutions.id as educational_institution_id', + 'educational_institutions.name as educational_institution_name', + 'direction_profiles.id as direction_profile_id', + 'entrance_examinations.scores as entrance_examination_score', + 'examination_types.name as examination_type_name', + 'subject_types.name as subject_type_name', + 'subjects.name as subject_name', + 'direction_profiles.name as direction_profile_name', + ) + ->get()->toArray(); + //phpcs:enable + $branches = []; + $directionsGroupWithOutBranch = array_reduce($directionsGroups, function ($acc, $direction) use (&$branches) { + + if ($direction['educational_institution_id'] == 3) { + $branches[] = $direction; + } + $acc[] = $direction; + return $acc; + }, []); + + $groupedDirections = collect($directionsGroupWithOutBranch) + ->reduce(function ($carry, $item, $key) use ($branches) { + [ + 'direction_id' => $directionId, + 'direction_name' => $directionName, + 'direction_code' => $directionCode, + 'educational_institution_id' => $educational_institution_id, + 'educational_institution_name' => $educationalInstitutionName, + 'faculty_id' => $facultyId, + 'faculty_name' => $facultyName, + 'faculty_description' => $facultyDescription, + 'education_level_name' => $educationLevelName, + 'education_form_name' => $educationFormName, + 'entrance_examination_score' => $entranceExaminationScore, + 'examination_type_name' => $examinationTypeName, + 'subject_type_name' => $subjectTypeName, + 'subject_name' => $subjectName, + 'direction_profile_name' => $directionProfileName, + 'direction_budget_places' => $directionBudgetPlaces, + 'direction_paid_places' => $directionPaidPlaces, + 'direction_cost_paid_place' => $directionCostPaidPlace, + 'direction_period' => $directionPeriod, + 'direction_description' => $directionDescription, + ] = $item; + + $carry[$facultyName]['id'] = $facultyId; + $carry[$facultyName]['name'] = $facultyName; + $carry[$facultyName]['description'] = $facultyDescription; + $carry[$facultyName]['directions'][$directionName]['name'] = $directionName; + $carry[$facultyName]['directions'][$directionName]['id'] = $directionId; + $carry[$facultyName]['directions'][$directionName]['code'] = $directionCode; + $carry[$facultyName]['directions'][$directionName]['education_level'] = $educationLevelName; + $carry[$facultyName]['directions'][$directionName]['education_form'][] = $educationFormName; + $carry[$facultyName]['directions'][$directionName]['education_form'] = array_unique( + $carry[$facultyName]['directions'][$directionName]['education_form'] + ); + $carry[$facultyName]['directions'][$directionName]['entrance_examinations'] + [$examinationTypeName][$subjectTypeName][$subjectName] = $entranceExaminationScore; + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionBudgetPlaces; + + + $carry[$facultyName]['directions'][$directionName]['paid_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionPaidPlaces; + + /*$carry[$facultyName]['directions'][$directionName] + ['paid_places'][$educationFormName] = $directionPaidPlaces;*/ + + + $carry[$facultyName]['directions'][$directionName] + ['cost_paid_place'][$educationFormName] = $directionCostPaidPlace; + $carry[$facultyName]['directions'][$directionName]['period'][$educationFormName] = $directionPeriod; + $carry[$facultyName]['directions'][$directionName]['description'] = $directionDescription; + + foreach ($branches as $branch) { + [ + 'direction_name' => $directionNameBranch, + 'educational_institution_name' => $educationalInstitutionNameBranch, + 'direction_profile_name' => $directionProfileNameBranch, + 'education_form_name' => $educationFormNameBranch, + 'direction_budget_places' => $directionBudgetPlacesBranch + ] = $branch; + if ($directionNameBranch === $directionName) { + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionNameBranch][$directionProfileNameBranch] + [$educationFormNameBranch] = $directionBudgetPlacesBranch; + } + } + + + return $carry; + }, []); + + return view('new-design.inostran', compact( + 'faculties', + 'subjects', + 'directionsWithInstitution', + 'groupedDirections', + 'admissions', + 'news', + )); + } + + public function magistr() + { + $news = News::all(); + $admissions = Admission::all(); + $faculties = Faculty::all(); + $subjects = EntranceExamination::all() + ->select('subject_id', 'subject_type_id', 'examination_type_id') + ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) + ->reduce(function (?array $carry, $subject) { + $id = $subject['subject_id']; + $value = Subject::find($id)->name; + $carry[$id] = $value; + return $carry; + }); + $directionsWithInstitution = Direction::with(['department']) + ->join('departments', 'directions.department_id', '=', 'departments.id') + ->join('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->join( + 'educational_institutions', + 'faculties.educational_institution_id', + '=', + 'educational_institutions.id' + ) + ->get([ + 'directions.id', + 'directions.name', + "educational_institutions.name as educational_institution_name" + ]); + //phpcs:disable + $directionsGroups = Direction::with(['department']) + ->leftJoin('direction_direction_profile', 'directions.id', '=', 'direction_direction_profile.direction_id') + ->leftJoin('direction_profiles','direction_direction_profile.direction_profile_id','=','direction_profiles.id') + ->leftJoin('departments', 'directions.department_id', '=', 'departments.id') + ->leftJoin('faculties', 'departments.faculty_id', '=', 'faculties.id') + ->leftJoin('education_levels', 'directions.education_level_id', '=', 'education_levels.id') + ->leftJoin('education_forms', 'directions.education_form_id', '=', 'education_forms.id') + ->leftJoin('entrance_examinations', 'entrance_examinations.direction_id', '=', 'directions.id') + ->leftJoin('educational_institutions','faculties.educational_institution_id','=','educational_institutions.id') + ->leftJoin('examination_types', 'entrance_examinations.examination_type_id', '=', 'examination_types.id') + ->leftJoin('subject_types', 'entrance_examinations.subject_type_id', '=', 'subject_types.id') + ->leftJoin('subjects', 'entrance_examinations.subject_id', '=', 'subjects.id') + ->select( + 'directions.id as direction_id', + 'directions.code as direction_code', + 'directions.name as direction_name', + 'directions.description as direction_description', + 'directions.budget_places as direction_budget_places', + 'directions.paid_places as direction_paid_places', + 'directions.cost_paid_place as direction_cost_paid_place', + 'directions.period as direction_period', + 'education_levels.name as education_level_name', + 'education_forms.name as education_form_name', + 'faculties.id as faculty_id', + 'faculties.name as faculty_name', + 'faculties.description as faculty_description', + 'educational_institutions.id as educational_institution_id', + 'educational_institutions.name as educational_institution_name', + 'direction_profiles.id as direction_profile_id', + 'entrance_examinations.scores as entrance_examination_score', + 'examination_types.name as examination_type_name', + 'subject_types.name as subject_type_name', + 'subjects.name as subject_name', + 'direction_profiles.name as direction_profile_name', + ) + ->get()->toArray(); + //phpcs:enable + $branches = []; + $directionsGroupWithOutBranch = array_reduce($directionsGroups, function ($acc, $direction) use (&$branches) { + + if ($direction['educational_institution_id'] == 3) { + $branches[] = $direction; + } + $acc[] = $direction; + return $acc; + }, []); + + $groupedDirections = collect($directionsGroupWithOutBranch) + ->reduce(function ($carry, $item, $key) use ($branches) { + [ + 'direction_id' => $directionId, + 'direction_name' => $directionName, + 'direction_code' => $directionCode, + 'educational_institution_id' => $educational_institution_id, + 'educational_institution_name' => $educationalInstitutionName, + 'faculty_id' => $facultyId, + 'faculty_name' => $facultyName, + 'faculty_description' => $facultyDescription, + 'education_level_name' => $educationLevelName, + 'education_form_name' => $educationFormName, + 'entrance_examination_score' => $entranceExaminationScore, + 'examination_type_name' => $examinationTypeName, + 'subject_type_name' => $subjectTypeName, + 'subject_name' => $subjectName, + 'direction_profile_name' => $directionProfileName, + 'direction_budget_places' => $directionBudgetPlaces, + 'direction_paid_places' => $directionPaidPlaces, + 'direction_cost_paid_place' => $directionCostPaidPlace, + 'direction_period' => $directionPeriod, + 'direction_description' => $directionDescription, + ] = $item; + + $carry[$facultyName]['id'] = $facultyId; + $carry[$facultyName]['name'] = $facultyName; + $carry[$facultyName]['description'] = $facultyDescription; + $carry[$facultyName]['directions'][$directionName]['name'] = $directionName; + $carry[$facultyName]['directions'][$directionName]['id'] = $directionId; + $carry[$facultyName]['directions'][$directionName]['code'] = $directionCode; + $carry[$facultyName]['directions'][$directionName]['education_level'] = $educationLevelName; + $carry[$facultyName]['directions'][$directionName]['education_form'][] = $educationFormName; + $carry[$facultyName]['directions'][$directionName]['education_form'] = array_unique( + $carry[$facultyName]['directions'][$directionName]['education_form'] + ); + $carry[$facultyName]['directions'][$directionName]['entrance_examinations'] + [$examinationTypeName][$subjectTypeName][$subjectName] = $entranceExaminationScore; + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionBudgetPlaces; + + + $carry[$facultyName]['directions'][$directionName]['paid_places'] + [$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionPaidPlaces; + + /*$carry[$facultyName]['directions'][$directionName] + ['paid_places'][$educationFormName] = $directionPaidPlaces;*/ + + + $carry[$facultyName]['directions'][$directionName] + ['cost_paid_place'][$educationFormName] = $directionCostPaidPlace; + $carry[$facultyName]['directions'][$directionName]['period'][$educationFormName] = $directionPeriod; + $carry[$facultyName]['directions'][$directionName]['description'] = $directionDescription; + + foreach ($branches as $branch) { + [ + 'direction_name' => $directionNameBranch, + 'educational_institution_name' => $educationalInstitutionNameBranch, + 'direction_profile_name' => $directionProfileNameBranch, + 'education_form_name' => $educationFormNameBranch, + 'direction_budget_places' => $directionBudgetPlacesBranch + ] = $branch; + if ($directionNameBranch === $directionName) { + $carry[$facultyName]['directions'][$directionName]['budget_places'] + [$educationalInstitutionNameBranch][$directionProfileNameBranch] + [$educationFormNameBranch] = $directionBudgetPlacesBranch; + } + } + + + return $carry; + }, []); + + return view('new-design.magistr', compact( + 'faculties', + 'subjects', + 'directionsWithInstitution', + 'groupedDirections', + 'admissions', + 'news', + )); + } + + + + public function calculator($request) + { + return response()->json($request); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/admin/UserController.php similarity index 85% rename from app/Http/Controllers/UserController.php rename to app/Http/Controllers/admin/UserController.php index c5c9a5a..a2f0d3c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/admin/UserController.php @@ -1,10 +1,10 @@ middleware('auth'); + $this->authorizeResource(User::class, 'user'); } + public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { abort_if(Auth::user()->name !== 'admin', 403); $users = User::all(); - return view('users.index', compact('users')); + return view('admin.users.index', compact('users')); } public function store(UpdateUserRequest $request): RedirectResponse @@ -46,14 +47,14 @@ class UserController extends Controller { abort_if(Auth::user()->name !== 'admin', 403); - return view('users.create'); + return view('admin.users.create'); } public function edit(User $user): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { abort_if(Auth::user()->name !== 'admin', 403); - return view('users.edit', compact('user')); + return view('admin.users.edit', compact('user')); } public function update(UpdateUserRequest $request, User $user): RedirectResponse diff --git a/app/Http/Requests/StoreDepartmentRequest.php b/app/Http/Requests/StoreDepartmentRequest.php deleted file mode 100644 index ec2bcde..0000000 --- a/app/Http/Requests/StoreDepartmentRequest.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ - public function rules(): array - { - return [ - 'position' => 'required|int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', - 'description' => 'string', - 'faculty_id' => 'required|int' - ]; - } -} diff --git a/app/Http/Requests/StoreEducationalInstitutionRequest.php b/app/Http/Requests/StoreEducationalInstitutionRequest.php deleted file mode 100644 index 8974bb5..0000000 --- a/app/Http/Requests/StoreEducationalInstitutionRequest.php +++ /dev/null @@ -1,30 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'position' => 'int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', - 'description' => 'string', - ]; - } -} diff --git a/app/Http/Requests/StoreFacultyRequest.php b/app/Http/Requests/StoreFacultyRequest.php deleted file mode 100644 index e274fe2..0000000 --- a/app/Http/Requests/StoreFacultyRequest.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ - public function rules(): array - { - return [ - 'position' => 'int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', - 'description' => 'string', - 'educational_institution_id' => 'int' - ]; - } -} diff --git a/app/Http/Requests/StoreFileRequest.php b/app/Http/Requests/StoreFileRequest.php deleted file mode 100644 index 16494be..0000000 --- a/app/Http/Requests/StoreFileRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'max:255', - 'position' => 'int|max:255', - 'url' => 'file', - 'idReceptionScreen' => 'int|max:255', - ]; - } -} diff --git a/app/Http/Requests/StoreReceptionScreenRequest.php b/app/Http/Requests/StoreReceptionScreenRequest.php deleted file mode 100644 index b03e0aa..0000000 --- a/app/Http/Requests/StoreReceptionScreenRequest.php +++ /dev/null @@ -1,29 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - ]; - } -} diff --git a/app/Http/Requests/UpdateDepartmentRequest.php b/app/Http/Requests/UpdateDepartmentRequest.php deleted file mode 100644 index eaf23dd..0000000 --- a/app/Http/Requests/UpdateDepartmentRequest.php +++ /dev/null @@ -1,37 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'position' => 'int|max:255', - 'description' => 'string', - 'faculty_id' => 'int|required', - 'name' => [ - 'required', - 'string', - 'max:255', - "unique:educational_institutions,name,{$this->department->id}", - ], - ]; - } -} diff --git a/app/Http/Requests/UpdateEducationalInstitutionRequest.php b/app/Http/Requests/UpdateEducationalInstitutionRequest.php deleted file mode 100644 index b89b640..0000000 --- a/app/Http/Requests/UpdateEducationalInstitutionRequest.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ - public function rules(): array - { - return [ - 'position' => 'int|max:255', - 'description' => 'string', - 'name' => [ - 'required', - 'string', - 'max:255', - "unique:educational_institutions,name,{$this->educational_institution->id}", - ], - ]; - } -} diff --git a/app/Http/Requests/UpdateFacultyRequest.php b/app/Http/Requests/UpdateFacultyRequest.php deleted file mode 100644 index 40b4f06..0000000 --- a/app/Http/Requests/UpdateFacultyRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -|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' - ]; - } -} diff --git a/app/Http/Requests/UpdateFileRequest.php b/app/Http/Requests/UpdateFileRequest.php deleted file mode 100644 index a9854c0..0000000 --- a/app/Http/Requests/UpdateFileRequest.php +++ /dev/null @@ -1,30 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - 'idReceptionScreen' => 'int|max:255', - ]; - } -} diff --git a/app/Http/Requests/UpdateReceptionScreenRequest.php b/app/Http/Requests/UpdateReceptionScreenRequest.php deleted file mode 100644 index dad4306..0000000 --- a/app/Http/Requests/UpdateReceptionScreenRequest.php +++ /dev/null @@ -1,29 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - ]; - } -} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreDirectionProfileRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreDirectionProfileRequest.php new file mode 100644 index 0000000..17eb20e --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreDirectionProfileRequest.php @@ -0,0 +1,40 @@ + 'required|string|max:255|unique:direction_profiles,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:direction_profiles,slug', + 'position' => 'required|int|numeric|max:255', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreEducationFormRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreEducationFormRequest.php new file mode 100644 index 0000000..e8953fd --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreEducationFormRequest.php @@ -0,0 +1,35 @@ + 'required|string|max:255|unique:education_levels,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:education_levels,slug', + ]; + } + + public function messages(): array + { + return [ + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreEducationLevelRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreEducationLevelRequest.php new file mode 100644 index 0000000..5a21e49 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreEducationLevelRequest.php @@ -0,0 +1,35 @@ + 'required|string|max:255|unique:education_levels,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:education_levels,slug', + ]; + } + + public function messages(): array + { + return [ + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php new file mode 100644 index 0000000..87d31a3 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php @@ -0,0 +1,55 @@ + 'required|numeric|int|max:1000', + 'examination_type_id' => 'required|numeric|int|max:1000', + 'subject_id' => 'required|numeric|int|max:1000', + 'subject_type_id' => 'required|numeric|int|max:1000', + 'scores' => 'required|numeric|int|max:100', + 'position' => 'required|numeric|int|max:1000', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'direction_id.required' => 'Поле позиция обязательно.', + 'direction_id.int' => 'Позиция должно быть целым числом.', + 'direction_id.numeric' => 'Позиция должно быть числом.', + 'direction_id.max' => 'Позиция не должен быть больше :max', + 'examination_type_id.required' => 'Поле позиция обязательно.', + 'examination_type_id.int' => 'Позиция должно быть целым числом.', + 'examination_type_id.numeric' => 'Позиция должно быть числом.', + 'examination_type_id.max' => 'Позиция не должен быть больше :max', + 'subject_id.required' => 'Поле позиция обязательно.', + 'subject_id.int' => 'Позиция должно быть целым числом.', + 'subject_id.numeric' => 'Позиция должно быть числом.', + 'subject_id.max' => 'Позиция не должен быть больше :max', + 'subject_type_id.required' => 'Поле позиция обязательно.', + 'subject_type_id.int' => 'Позиция должно быть целым числом.', + 'subject_type_id.numeric' => 'Позиция должно быть числом.', + 'subject_type_id.max' => 'Позиция не должен быть больше :max', + 'scores.required' => 'Поле позиция обязательно.', + 'scores.int' => 'Позиция должно быть целым числом.', + 'scores.numeric' => 'Позиция должно быть числом.', + 'scores.max' => 'Позиция не должен быть больше :max', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php new file mode 100644 index 0000000..a05abfd --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreExaminationTypeRequest.php @@ -0,0 +1,39 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:examination_types,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:examination_types,slug', + ]; + } + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreSubjectRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreSubjectRequest.php new file mode 100644 index 0000000..01eeba5 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreSubjectRequest.php @@ -0,0 +1,40 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:subjects,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:subjects,slug', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreSubjectTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreSubjectTypeRequest.php new file mode 100644 index 0000000..68048aa --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreSubjectTypeRequest.php @@ -0,0 +1,40 @@ + 'required|string|max:255|unique:subject_types,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:subject_types,slug', + 'position' => 'required|int|numeric|max:255', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateDirectionProfileRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateDirectionProfileRequest.php new file mode 100644 index 0000000..13b58dd --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateDirectionProfileRequest.php @@ -0,0 +1,50 @@ + [ + 'required', + 'string', + 'max:255', + "unique:direction_profiles,name,{$this->direction_profile->id}" + ], + 'description' => 'nullable|string', + 'slug' => [ + 'required', + 'string', + 'max:255', + "unique:direction_profiles,slug,{$this->direction_profile->id}" + ], + 'position' => 'required|int|numeric|max:255', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateEducationFormRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateEducationFormRequest.php new file mode 100644 index 0000000..a9d524a --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateEducationFormRequest.php @@ -0,0 +1,35 @@ + "required|string|max:255|unique:education_forms,name,{$this->education_form->id}", + 'description' => 'nullable|string', + 'slug' => "required|string|max:255|unique:education_forms,slug,{$this->education_form->id}", + ]; + } + + public function messages(): array + { + return [ + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateEducationLevelRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateEducationLevelRequest.php new file mode 100644 index 0000000..9948307 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateEducationLevelRequest.php @@ -0,0 +1,35 @@ + "required|string|max:255|unique:education_levels,name,{$this->education_level->id}", + 'description' => 'nullable|string', + 'slug' => "required|string|max:255|unique:education_levels,slug,{$this->education_level->id}", + ]; + } + + public function messages(): array + { + return [ + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php new file mode 100644 index 0000000..4c46a9d --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateEntranceExaminationRequest.php @@ -0,0 +1,55 @@ + 'required|numeric|int|max:1000', + 'examination_type_id' => 'required|numeric|int|max:1000', + 'subject_id' => 'required|numeric|int|max:1000', + 'subject_type_id' => 'required|numeric|int|max:1000', + 'scores' => 'required|numeric|int|max:100', + 'position' => 'required|numeric|int|max:1000', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'direction_id.required' => 'Поле позиция обязательно.', + 'direction_id.int' => 'Позиция должно быть целым числом.', + 'direction_id.numeric' => 'Позиция должно быть числом.', + 'direction_id.max' => 'Позиция не должен быть больше :max', + 'examination_type_id.required' => 'Поле позиция обязательно.', + 'examination_type_id.int' => 'Позиция должно быть целым числом.', + 'examination_type_id.numeric' => 'Позиция должно быть числом.', + 'examination_type_id.max' => 'Позиция не должен быть больше :max', + 'subject_id.required' => 'Поле позиция обязательно.', + 'subject_id.int' => 'Позиция должно быть целым числом.', + 'subject_id.numeric' => 'Позиция должно быть числом.', + 'subject_id.max' => 'Позиция не должен быть больше :max', + 'subject_type_id.required' => 'Поле позиция обязательно.', + 'subject_type_id.int' => 'Позиция должно быть целым числом.', + 'subject_type_id.numeric' => 'Позиция должно быть числом.', + 'subject_type_id.max' => 'Позиция не должен быть больше :max', + 'scores.required' => 'Поле позиция обязательно.', + 'scores.int' => 'Позиция должно быть целым числом.', + 'scores.numeric' => 'Позиция должно быть числом.', + 'scores.max' => 'Позиция не должен быть больше :max', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php new file mode 100644 index 0000000..d772aba --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateExaminationTypeRequest.php @@ -0,0 +1,50 @@ + 'required|int|numeric|max:255', + 'description' => 'nullable|string', + 'slug' => [ + 'string', + 'required', + 'max:255', + "unique:examination_types,slug,{$this->examination_type->id}", + ], + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:examination_types,name,{$this->examination_type->id}", + ], + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectRequest.php new file mode 100644 index 0000000..32760ec --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectRequest.php @@ -0,0 +1,33 @@ + 'required|int|numeric|max:255', + 'description' => 'nullable|string', + 'slug' => [ + 'string', + 'required', + 'max:255', + "unique:subjects,slug,{$this->subject->id}", + ], + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:subjects,name,{$this->subject->id}", + ], + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectTypeRequest.php b/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectTypeRequest.php new file mode 100644 index 0000000..08f745f --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/UpdateSubjectTypeRequest.php @@ -0,0 +1,50 @@ + 'required|int|numeric|max:255', + 'description' => 'nullable|string', + 'slug' => [ + 'string', + 'required', + 'max:255', + "unique:subject_types,slug,{$this->subject_type->id}", + ], + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:subject_types,name,{$this->subject_type->id}", + ], + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php b/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php new file mode 100644 index 0000000..59c925a --- /dev/null +++ b/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php @@ -0,0 +1,46 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:departments,slug', + 'faculty_id' => 'required|numeric|int|max:1000', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'faculty_id.required' => 'Поле учебное заведение обязательно.', + 'faculty_id.int' => 'Учебное заведение должно быть целым числом.', + 'faculty_id.numeric' => 'Учебное заведение должно быть числом.', + 'faculty_id.max' => 'Поле учебное заведение не должен быть больше :max.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php b/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php new file mode 100644 index 0000000..e98463d --- /dev/null +++ b/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php @@ -0,0 +1,121 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:directions,slug', + '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', + 'entrance-examination.*.examination_type_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.subject_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.subject_type_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.scores' => 'required|numeric|int|max:1000', + 'entrance-examination.*.position' => 'required|numeric|int|max:1000', + 'budget_places' => 'required|int|numeric|max:255', + 'paid_places' => 'required|int|numeric|max:255', + 'quota' => 'required|int|numeric|max:255', + 'cost_paid_place' => 'required|int|numeric|max:200000', + 'period' => 'required|numeric|max:255', + 'direction_profiles' => 'nullable|array' + ]; + } + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'code.required' => 'Поле Код обязательно.', + 'code.string' => 'Поле Код должен быть строкой.', + 'code.max' => 'Код не должен быть длиннее :max', + 'education_level_id.required' => 'Поле "уровень образования" обязательно.', + 'education_level_id.int' => 'Поле "уровень образования" должно быть целым числом.', + 'education_level_id.numeric' => 'Поле "уровень образования" должно быть числом.', + 'education_level_id.max' => 'Поле "уровень образования" не должен быть больше :max', + 'education_form_id.required' => 'Поле "форма образования" обязательно.', + 'education_form_id.int' => 'Поле "форма образования" должно быть целым числом.', + 'education_form_id.numeric' => 'Поле "форма образования" должно быть числом.', + 'education_form_id.max' => 'Поле "форма образования" не должен быть больше :max', + 'department_id.required' => 'Поле "Кафедра" обязательно.', + 'department_id.int' => 'Поле "Кафедра" должно быть целым числом.', + 'department_id.numeric' => 'Поле "Кафедра" должно быть числом.', + 'department_id.max' => 'Поле "Кафедра" не должен быть больше :max', + + 'entrance-examination.*.position.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.position.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.position.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.position.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.direction_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.direction_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.direction_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.direction_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.examination_type_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.examination_type_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.examination_type_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.examination_type_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.subject_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.subject_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.subject_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.subject_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.subject_type_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.subject_type_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.subject_type_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.subject_type_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.scores.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.scores.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.scores.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.scores.max' => 'Позиция не должен быть больше :max', + + 'budget_places.required' => 'Поле Кол-во бюджетных мест обязательно.', + 'budget_places.int' => 'Кол-во бюджетных мест должно быть целым числом.', + 'budget_places.numeric' => 'Кол-во бюджетных мест должно быть числом.', + 'budget_places.max' => 'Кол-во бюджетных мест не должен быть больше :max', + + 'paid_places.required' => 'Поле Кол-во мест по договорам обязательно.', + 'paid_places.int' => 'Кол-во мест по договорам должно быть целым числом.', + 'paid_places.numeric' => 'Кол-во мест по договорам должно быть числом.', + 'paid_places.max' => 'Кол-во мест по договорам не должен быть больше :max', + + 'quota.required' => 'Поле Квота обязательно.', + 'quota.int' => 'Квота должно быть целым числом.', + 'quota.numeric' => 'Квота должно быть числом.', + 'quota.max' => 'Квота не должен быть больше :max', + + 'cost_paid_place.required' => 'Поле Стоимость обучения обязательно.', + 'cost_paid_place.int' => 'Стоимость обучения должно быть целым числом.', + 'cost_paid_place.numeric' => 'Стоимость обучения должно быть числом.', + 'cost_paid_place.max' => 'Стоимость обучения не должен быть больше :max', + + 'period.required' => 'Поле Период обучения обязательно.', + 'period.int' => 'Период обучения должно быть целым числом.', + 'period.numeric' => 'Период обучения должно быть числом.', + 'period.max' => 'Период обучения не должен быть больше :max', + + 'direction_profiles.array' => 'Поле Профиль подготовки должно быть массивом.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php b/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php new file mode 100644 index 0000000..5932d61 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php @@ -0,0 +1,39 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:educational_institutions,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:educational_institutions,slug', + ]; + } + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php b/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php new file mode 100644 index 0000000..802cb38 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php @@ -0,0 +1,46 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:faculties,name', + 'description' => 'nullable|string', + 'slug' => 'nullable|string|max:255|unique:faculties,slug', + 'educational_institution_id' => 'required|int|numeric|max:1000' + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'educational_institution_id.required' => 'Поле учебное заведение обязательно.', + 'educational_institution_id.int' => 'Учебное заведение должно быть целым числом.', + 'educational_institution_id.numeric' => 'Учебное заведение должно быть числом.', + 'educational_institution_id.max' => 'Поле учебное заведение не должен быть больше :max.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php b/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php new file mode 100644 index 0000000..67f3109 --- /dev/null +++ b/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php @@ -0,0 +1,53 @@ + 'required|int|numeric|max:255', + 'description' => 'nullable|string', + 'slug' => [ + 'string', + 'required', + 'max:255', + "unique:departments,slug,{$this->department->id}", + ], + 'faculty_id' => 'int|required|numeric|max:255', + 'name' => [ + 'required', + 'string', + 'max:255' + ], + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'faculty_id.required' => 'Поле учебное заведение обязательно.', + 'faculty_id.int' => 'Учебное заведение должно быть целым числом.', + 'faculty_id.numeric' => 'Учебное заведение должно быть числом.', + 'faculty_id.max' => 'Поле учебное заведение не должен быть больше :max.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php b/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php new file mode 100644 index 0000000..dd8937c --- /dev/null +++ b/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php @@ -0,0 +1,123 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255', + 'description' => 'nullable|string', + 'slug' => "required|string|max:255|unique:directions,slug,{$this->direction->id}", + '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', + 'entrance-examination.*.examination_type_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.subject_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.subject_type_id' => 'required|numeric|int|max:1000', + 'entrance-examination.*.scores' => 'required|numeric|int|max:1000', + 'entrance-examination.*.position' => 'required|numeric|int|max:1000', + 'budget_places' => 'required|int|numeric|max:255', + 'paid_places' => 'required|int|numeric|max:255', + 'quota' => 'required|int|numeric|max:255', + 'cost_paid_place' => 'required|int|numeric|max:200000', + 'period' => 'required|numeric|max:255', + 'direction_profiles' => 'nullable|array', + 'delete.*' => 'nullable|array' + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'code.required' => 'Поле Код обязательно.', + 'code.string' => 'Поле Код должен быть строкой.', + 'code.max' => 'Код не должен быть длиннее :max', + 'education_level_id.required' => 'Поле "уровень образования" обязательно.', + 'education_level_id.int' => 'Поле "уровень образования" должно быть целым числом.', + 'education_level_id.numeric' => 'Поле "уровень образования" должно быть числом.', + 'education_level_id.max' => 'Поле "уровень образования" не должен быть больше :max', + 'education_form_id.required' => 'Поле "форма образования" обязательно.', + 'education_form_id.int' => 'Поле "форма образования" должно быть целым числом.', + 'education_form_id.numeric' => 'Поле "форма образования" должно быть числом.', + 'education_form_id.max' => 'Поле "форма образования" не должен быть больше :max', + 'department_id.required' => 'Поле "Кафедра" обязательно.', + 'department_id.int' => 'Поле "Кафедра" должно быть целым числом.', + 'department_id.numeric' => 'Поле "Кафедра" должно быть числом.', + 'department_id.max' => 'Поле "Кафедра" не должен быть больше :max', + + 'entrance-examination.*.position.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.position.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.position.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.position.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.direction_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.direction_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.direction_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.direction_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.examination_type_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.examination_type_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.examination_type_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.examination_type_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.subject_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.subject_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.subject_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.subject_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.subject_type_id.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.subject_type_id.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.subject_type_id.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.subject_type_id.max' => 'Позиция не должен быть больше :max', + 'entrance-examination.*.scores.required' => 'Поле позиция обязательно.', + 'entrance-examination.*.scores.int' => 'Позиция должно быть целым числом.', + 'entrance-examination.*.scores.numeric' => 'Позиция должно быть числом.', + 'entrance-examination.*.scores.max' => 'Позиция не должен быть больше :max', + + 'budget_places.required' => 'Поле Кол-во бюджетных мест обязательно.', + 'budget_places.int' => 'Кол-во бюджетных мест должно быть целым числом.', + 'budget_places.numeric' => 'Кол-во бюджетных мест должно быть числом.', + 'budget_places.max' => 'Кол-во бюджетных мест не должен быть больше :max', + + 'paid_places.required' => 'Поле Кол-во мест по договорам обязательно.', + 'paid_places.int' => 'Кол-во мест по договорам должно быть целым числом.', + 'paid_places.numeric' => 'Кол-во мест по договорам должно быть числом.', + 'paid_places.max' => 'Кол-во мест по договорам не должен быть больше :max', + + 'quota.required' => 'Поле Квота обязательно.', + 'quota.int' => 'Квота должно быть целым числом.', + 'quota.numeric' => 'Квота должно быть числом.', + 'quota.max' => 'Квота не должен быть больше :max', + + 'cost_paid_place.required' => 'Поле Стоимость обучения обязательно.', + 'cost_paid_place.int' => 'Стоимость обучения должно быть целым числом.', + 'cost_paid_place.numeric' => 'Стоимость обучения должно быть числом.', + 'cost_paid_place.max' => 'Стоимость обучения не должен быть больше :max', + + 'period.required' => 'Поле Период обучения обязательно.', + 'period.int' => 'Период обучения должно быть целым числом.', + 'period.numeric' => 'Период обучения должно быть числом.', + 'period.max' => 'Период обучения не должен быть больше :max', + + 'direction_profiles.array' => 'Поле Профиль подготовки должно быть массивом.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php b/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php new file mode 100644 index 0000000..e64268a --- /dev/null +++ b/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php @@ -0,0 +1,51 @@ + 'required|int|numeric|max:255', + 'description' => 'nullable|string', + 'slug' => [ + 'required', + 'string', + 'max:255', + "unique:educational_institutions,slug,{$this->educational_institution->id}", + ], + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:educational_institutions,name,{$this->educational_institution->id}", + ], + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + ]; + } +} diff --git a/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php b/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php new file mode 100644 index 0000000..5cb1e7c --- /dev/null +++ b/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php @@ -0,0 +1,45 @@ + 'required|int|numeric|max:255', + 'name' => ['required', 'string', 'max:255', "unique:faculties,name,{$this->faculty->id}"], + 'description' => 'nullable|string', + 'slug' => ['required', 'string', 'max:255', "unique:faculties,slug,{$this->faculty->id}"], + 'educational_institution_id' => 'required|int|numeric|max:1000', + ]; + } + + public function messages(): array + { + return [ + 'position.required' => 'Поле позиция обязательно.', + 'position.int' => 'Позиция должно быть целым числом.', + 'position.numeric' => 'Позиция должно быть числом.', + 'position.max' => 'Позиция не должен быть больше :max', + 'name.required' => 'Поле название обязательно.', + 'name.string' => 'Поле название должен быть строкой.', + 'name.max' => 'Поле название не должен превышать :max символов.', + 'name.unique' => 'Название уже занят.', + 'description.string' => 'Поле описание должен быть строкой.', + 'slug.string' => 'Поле URL должен быть строкой.', + 'slug.max' => 'Поле URL не должен превышать :max символов.', + 'educational_institution_id.required' => 'Поле учебное заведение обязательно.', + 'educational_institution_id.int' => 'Учебное заведение должно быть целым числом.', + 'educational_institution_id.numeric' => 'Учебное заведение должно быть числом.', + 'educational_institution_id.max' => 'Поле учебное заведение не должен быть больше :max.', + ]; + } +} diff --git a/app/Http/Requests/admin/StoreAdmissionRequest.php b/app/Http/Requests/admin/StoreAdmissionRequest.php new file mode 100644 index 0000000..e668797 --- /dev/null +++ b/app/Http/Requests/admin/StoreAdmissionRequest.php @@ -0,0 +1,23 @@ + 'required|int|numeric|max:255', + 'name' => 'required|string|max:255|unique:admissions,name', + 'description' => 'string', + 'slug' => 'required|string|max:255', + ]; + } +} diff --git a/app/Http/Requests/admin/StoreDocumentRequest.php b/app/Http/Requests/admin/StoreDocumentRequest.php new file mode 100644 index 0000000..78e9a41 --- /dev/null +++ b/app/Http/Requests/admin/StoreDocumentRequest.php @@ -0,0 +1,25 @@ + 'required|string|max:255', + 'description' => 'string', + 'position' => 'required|int|numeric|max:255', + 'document' => 'required|file', + 'admission_id' => 'required|int|numeric|max:1000', + ]; + } +} diff --git a/app/Http/Requests/admin/StoreNewsRequest.php b/app/Http/Requests/admin/StoreNewsRequest.php new file mode 100644 index 0000000..5f92520 --- /dev/null +++ b/app/Http/Requests/admin/StoreNewsRequest.php @@ -0,0 +1,22 @@ + 'required|string|max:255', + 'text' => 'string', + 'photo' => 'required|file', + ]; + } +} diff --git a/app/Http/Requests/StoreUserRequest.php b/app/Http/Requests/admin/StoreUserRequest.php similarity index 53% rename from app/Http/Requests/StoreUserRequest.php rename to app/Http/Requests/admin/StoreUserRequest.php index ec4535d..fbf1496 100644 --- a/app/Http/Requests/StoreUserRequest.php +++ b/app/Http/Requests/admin/StoreUserRequest.php @@ -1,31 +1,21 @@ - */ public function rules() { return [ 'name' => 'required|unique:users,name|max:255', - 'email' => 'email', + 'email' => 'email|string|max:255', 'password' => 'required' ]; } diff --git a/app/Http/Requests/admin/UpdateAdmissionRequest.php b/app/Http/Requests/admin/UpdateAdmissionRequest.php new file mode 100644 index 0000000..cd86338 --- /dev/null +++ b/app/Http/Requests/admin/UpdateAdmissionRequest.php @@ -0,0 +1,28 @@ + 'required|int|numeric|max:255', + 'description' => 'string', + 'slug' => 'string|required|max:255', + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:admissions,name,{$this->admission->id}", + ], + ]; + } +} diff --git a/app/Http/Requests/admin/UpdateDocumentRequest.php b/app/Http/Requests/admin/UpdateDocumentRequest.php new file mode 100644 index 0000000..003aa81 --- /dev/null +++ b/app/Http/Requests/admin/UpdateDocumentRequest.php @@ -0,0 +1,28 @@ + [ + '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', + ]; + } +} diff --git a/app/Http/Requests/admin/UpdateNewsRequest.php b/app/Http/Requests/admin/UpdateNewsRequest.php new file mode 100644 index 0000000..e72b94f --- /dev/null +++ b/app/Http/Requests/admin/UpdateNewsRequest.php @@ -0,0 +1,21 @@ + 'required|string|max:255', + 'text' => 'string', + ]; + } +} diff --git a/app/Http/Requests/UpdateUserRequest.php b/app/Http/Requests/admin/UpdateUserRequest.php similarity index 72% rename from app/Http/Requests/UpdateUserRequest.php rename to app/Http/Requests/admin/UpdateUserRequest.php index c4fc40a..0610356 100644 --- a/app/Http/Requests/UpdateUserRequest.php +++ b/app/Http/Requests/admin/UpdateUserRequest.php @@ -1,6 +1,6 @@ 'required|max:255', - 'email' => 'email', - 'password' => 'required' + 'name' => 'required|string|max:255', + 'email' => 'email|string|max:255', + 'password' => 'required|max:255' ]; } } diff --git a/app/Models/ReceptionScreen.php b/app/Models/Admission.php similarity index 67% rename from app/Models/ReceptionScreen.php rename to app/Models/Admission.php index ae66db4..a556810 100644 --- a/app/Models/ReceptionScreen.php +++ b/app/Models/Admission.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -class ReceptionScreen extends Model +class Admission extends Model { use HasFactory; @@ -16,8 +16,8 @@ class ReceptionScreen extends Model 'position' ]; - public function files(): HasMany + public function documents(): HasMany { - return $this->hasMany('App\Models\File', 'reception_screen_id'); + return $this->hasMany('App\Models\Document', 'admission_id'); } } diff --git a/app/Models/Department.php b/app/Models/Department.php index f691ec8..91517cb 100644 --- a/app/Models/Department.php +++ b/app/Models/Department.php @@ -5,6 +5,7 @@ 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 { @@ -13,6 +14,7 @@ class Department extends Model protected $fillable = [ 'id', 'name', + 'slug', 'description', 'position', ]; @@ -21,4 +23,9 @@ class Department extends Model { return $this->belongsTo(Faculty::class); } + + public function directions(): HasMany + { + return $this->hasMany('App\Models\Direction', 'department_id'); + } } diff --git a/app/Models/Direction.php b/app/Models/Direction.php new file mode 100644 index 0000000..f6a0804 --- /dev/null +++ b/app/Models/Direction.php @@ -0,0 +1,56 @@ +belongsTo(Department::class); + } + + public function educationLevel(): BelongsTo + { + return $this->belongsTo(EducationLevel::class); + } + + public function educationForm(): BelongsTo + { + return $this->belongsTo(EducationForm::class); + } + + public function entranceExaminations(): HasMany + { + return $this->hasMany('App\Models\EntranceExamination', 'direction_id'); + } + + + + public function directionProfiles(): BelongsToMany + { + return $this->belongsToMany(DirectionProfile::class); + } +} diff --git a/app/Models/DirectionProfile.php b/app/Models/DirectionProfile.php new file mode 100644 index 0000000..4b8dc1b --- /dev/null +++ b/app/Models/DirectionProfile.php @@ -0,0 +1,26 @@ +belongsToMany(Direction::class); + } +} diff --git a/app/Models/File.php b/app/Models/Document.php similarity index 72% rename from app/Models/File.php rename to app/Models/Document.php index bd9c20b..69b5999 100644 --- a/app/Models/File.php +++ b/app/Models/Document.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -class File extends Model +class Document extends Model { use HasFactory; @@ -18,8 +18,8 @@ class File extends Model 'description', ]; - public function receptionScreen(): BelongsTo + public function admission(): BelongsTo { - return $this->belongsTo(ReceptionScreen::class); + return $this->belongsTo(Admission::class); } } diff --git a/app/Models/EducationForm.php b/app/Models/EducationForm.php new file mode 100644 index 0000000..94bb1f6 --- /dev/null +++ b/app/Models/EducationForm.php @@ -0,0 +1,24 @@ +hasMany('App\Models\Direction', 'education_form_id'); + } +} diff --git a/app/Models/EducationLevel.php b/app/Models/EducationLevel.php new file mode 100644 index 0000000..cd879d3 --- /dev/null +++ b/app/Models/EducationLevel.php @@ -0,0 +1,24 @@ +hasMany('App\Models\Direction', 'education_level_id'); + } +} diff --git a/app/Models/EducationalInstitution.php b/app/Models/EducationalInstitution.php index db0ac50..135c707 100644 --- a/app/Models/EducationalInstitution.php +++ b/app/Models/EducationalInstitution.php @@ -13,6 +13,7 @@ class EducationalInstitution extends Model protected $fillable = [ 'id', 'name', + 'slug', 'description', 'position', ]; diff --git a/app/Models/EntranceExamination.php b/app/Models/EntranceExamination.php new file mode 100644 index 0000000..9ca35cc --- /dev/null +++ b/app/Models/EntranceExamination.php @@ -0,0 +1,42 @@ +belongsTo(ExaminationType::class); + } + + public function direction(): BelongsTo + { + return $this->belongsTo(Direction::class); + } + + public function subject(): BelongsTo + { + return $this->belongsTo(Subject::class); + } + + public function subjectType(): BelongsTo + { + return $this->belongsTo(SubjectType::class); + } +} diff --git a/app/Models/ExaminationType.php b/app/Models/ExaminationType.php new file mode 100644 index 0000000..f58bc48 --- /dev/null +++ b/app/Models/ExaminationType.php @@ -0,0 +1,25 @@ +hasMany('App\Models\EntranceExamination', 'examination_type_id'); + } +} diff --git a/app/Models/Faculty.php b/app/Models/Faculty.php index 5f65286..2a48d31 100644 --- a/app/Models/Faculty.php +++ b/app/Models/Faculty.php @@ -15,6 +15,7 @@ class Faculty extends Model 'id', 'name', 'description', + 'slug', 'position', ]; diff --git a/app/Models/News.php b/app/Models/News.php new file mode 100644 index 0000000..468d8a8 --- /dev/null +++ b/app/Models/News.php @@ -0,0 +1,19 @@ +hasMany('App\Models\EntranceExamination', 'subject_id'); + } +} diff --git a/app/Models/SubjectType.php b/app/Models/SubjectType.php new file mode 100644 index 0000000..a95c56e --- /dev/null +++ b/app/Models/SubjectType.php @@ -0,0 +1,25 @@ +hasMany('App\Models\EntranceExamination', 'subject_type_id'); + } +} diff --git a/app/Policies/DepartmentPolicy.php b/app/Policies/DepartmentPolicy.php deleted file mode 100644 index e60adbd..0000000 --- a/app/Policies/DepartmentPolicy.php +++ /dev/null @@ -1,66 +0,0 @@ -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'); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..934f1ae 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,23 +2,20 @@ namespace App\Providers; +use Illuminate\Routing\UrlGenerator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { - /** - * Register any application services. - */ public function register(): void { // } - /** - * Bootstrap any application services. - */ - public function boot(): void + public function boot(UrlGenerator $url): void { - // + if (env('APP_ENV') == 'production') { + $url->forceScheme('https'); + } } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 54756cd..db9607e 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -3,6 +3,8 @@ 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 @@ -13,7 +15,7 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - // + User::class => UserPolicy::class, ]; /** diff --git a/app/Services/DirectonHtmlBuilder.php b/app/Services/DirectonHtmlBuilder.php new file mode 100644 index 0000000..7c5b581 --- /dev/null +++ b/app/Services/DirectonHtmlBuilder.php @@ -0,0 +1,276 @@ +direction = $direction; + } + + public function getHTML() + { + $direction = $this->direction; + $fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png'); + + $green_circle = URL::to('img/front-page/green-circle.png'); + + $education_form = ''; + foreach ($direction['education_form'] as $el) { + $education_form .= $el . ', '; + } + $education_form = substr($education_form, 0, -2); + + + $period = '
'; + foreach ($direction['period'] as $key => $el) { + $period .= '' . $key . ' - ' . '' . $el . '
' ; + } + + + //dd($direction); + + $paid_cost = '
+ Стоимость обучения +
+ +
'; + foreach ($direction['cost_paid_place'] as $key => $el) { + $paid_cost .= '' . $key . ' - ' . '' . $el . '
' ; + } + $paid_cost .= '
'; + + + + + $EGE = '
+ ЕГЭ +
+ +
'; + foreach ($direction['entrance_examinations']['ЕГЭ']['Обязательные'] as $key => $el) { + $EGE .= '' . $key . ' - ' . '' . $el . '
' ; + } + $EGE .= '
'; + + $po_viboru = '
+ Предметы по выбору +
+ +
'; + if (array_key_exists('Предметы по выбору', $direction['entrance_examinations']['ЕГЭ'])) { + foreach ($direction['entrance_examinations']['ЕГЭ']['Предметы по выбору'] as $key => $el) { + $po_viboru .= '' . $key . ' - ' . '' . $el . '
' ; + } + $po_viboru .= '
'; + } else { + $po_viboru = ''; + } + + + $SPO = '
+ СПО +
+ +
'; + if (array_key_exists('СПО', $direction['entrance_examinations'])) { + foreach ($direction['entrance_examinations']['СПО']['Обязательные'] as $key => $el) { + $SPO .= '' . $key . ' - ' . '' . $el . '
' ; + } + $SPO .= '
'; + } else { + $SPO = ''; + } + + + + $mgtu = ''; + if (array_key_exists('МГТУ', $direction['budget_places'])) { + foreach ($direction['budget_places']['МГТУ'] as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $budget_places) { + $profile_content .= " {$forms} - " . " {$budget_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $mgtu .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } +// if($direction['name'] == 'Нефтегазовое дело') { +// dd($direction); +// }; +// dd($direction); + + + + + + $filial = ''; + if (array_key_exists('Филиал МГТУ (пос. Яблоновский)', $direction['budget_places'])) { + foreach ($direction['budget_places']['Филиал МГТУ (пос. Яблоновский)'] as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $budget_places) { + $profile_content .= " {$forms} - " . " {$budget_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $filial .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } else { + $filial = '
Этой специальности нет в филиалле
'; + } + $paid_places_content = ''; + foreach ($direction['paid_places'] as $institution) { + foreach ($institution as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $paid_places) { + $profile_content .= " {$forms} - " . " {$paid_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $paid_places_content .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } + + + return "
+ + +
+
+ +
+
+
+
+
{$direction['code']}
+
{$direction['name']}
+
+
+
+ + + + +
+
+
+
+
+

{$direction['description']}

+
+
+
+ +
+
+
Уровень образования: + {$direction['education_level']} +
+
Форма обучения: + {$education_form} +
+
Период обучения (в годах): + $period +
+
+
+
+
+ Места для обучения:
+
+
+
+
+

Бюджет

+ +
{$mgtu}
+
+ + +
+

Коммерция

+
$paid_places_content
+ +
+
+ + +
+
+
+
+
+
+
+ Проходные баллы: +
+ $EGE $po_viboru $SPO +
+ + +
+
+
+
+ $paid_cost +
+
+
+
+
+ "; + } + // phpcs:enable +} diff --git a/app/Services/DirectonHtmlBuilderForCalculator.php b/app/Services/DirectonHtmlBuilderForCalculator.php new file mode 100644 index 0000000..bfcd94c --- /dev/null +++ b/app/Services/DirectonHtmlBuilderForCalculator.php @@ -0,0 +1,276 @@ +direction = $direction; + } + + public function getHTML() + { + $direction = $this->direction; + $fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png'); + + $green_circle = URL::to('img/front-page/green-circle.png'); + + $education_form = ''; + foreach ($direction['education_form'] as $el) { + $education_form .= $el . ', '; + } + $education_form = substr($education_form, 0, -2); + + + $period = '
'; + foreach ($direction['period'] as $key => $el) { + $period .= '' . $key . ' - ' . '' . $el . '
' ; + } + + + //dd($direction); + + $paid_cost = '
+ Стоимость обучения +
+
+
'; + foreach ($direction['cost_paid_place'] as $key => $el) { + $paid_cost .= '' . $key . ' - ' . '' . $el . '
' ; + } + $paid_cost .= '
'; + + + + + $EGE = '
+ ЕГЭ +
+
+
'; + foreach ($direction['entrance_examinations']['ЕГЭ']['Обязательные'] as $key => $el) { + $EGE .= '' . $key . ' - ' . '' . $el . '
' ; + } + $EGE .= '
'; + + $po_viboru = '
+ Предметы по выбору +
+
+
'; + if (array_key_exists('Предметы по выбору', $direction['entrance_examinations']['ЕГЭ'])) { + foreach ($direction['entrance_examinations']['ЕГЭ']['Предметы по выбору'] as $key => $el) { + $po_viboru .= '' . $key . ' - ' . '' . $el . '
' ; + } + $po_viboru .= '
'; + } else { + $po_viboru = ''; + } + + + $SPO = '
+ СПО +
+
+
'; + if (array_key_exists('СПО', $direction['entrance_examinations'])) { + foreach ($direction['entrance_examinations']['СПО']['Обязательные'] as $key => $el) { + $SPO .= '' . $key . ' - ' . '' . $el . '
' ; + } + $SPO .= '
'; + } else { + $SPO = ''; + } + + + + $mgtu = ''; + if (array_key_exists('МГТУ', $direction['budget_places'])) { + foreach ($direction['budget_places']['МГТУ'] as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $budget_places) { + $profile_content .= " {$forms} - " . " {$budget_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $mgtu .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } +// if($direction['name'] == 'Нефтегазовое дело') { +// dd($direction); +// }; +// dd($direction); + + + + + + $filial = ''; + if (array_key_exists('Филиал МГТУ (пос. Яблоновский)', $direction['budget_places'])) { + foreach ($direction['budget_places']['Филиал МГТУ (пос. Яблоновский)'] as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $budget_places) { + $profile_content .= " {$forms} - " . " {$budget_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $filial .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } else { + $filial = '
Этой специальности нет в филиалле
'; + } + $paid_places_content = ''; + foreach ($direction['paid_places'] as $institution) { + foreach ($institution as $profile_name => $profile) { + $profile_content = ''; + foreach ($profile as $forms => $paid_places) { + $profile_content .= " {$forms} - " . " {$paid_places}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $tmp = str_replace(',', '', $tmp); + $paid_places_content .= "
+
+

+ +

+
+
+ $profile_content +
+
+
+
" ; + } + } + + + return "
+ + +
+
+ +
+
+
+
+
{$direction['code']}
+
{$direction['name']}
+
+
+
+ + + + +
+
+
+
+
+

{$direction['description']}

+
+
+
+ +
+
+
Уровень образования: + {$direction['education_level']} +
+
Форма обучения: + {$education_form} +
+
Период обучения (в годах): + $period +
+
+
+
+
+ Места для обучения:
+
+
+
+
+

Бюджет

+ +
{$mgtu}
+
+ + +
+

Коммерция

+
$paid_places_content
+ +
+
+ + +
+
+
+
+
+
+
+ Проходные баллы: +
+ $EGE $po_viboru $SPO +
+ + +
+
+
+
+ $paid_cost +
+
+
+
+
+ "; + } + // phpcs:enable +} diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index bc479ad..7342aaa 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -4,71 +4,11 @@ namespace App\Services; use DiDom\Document; -/* -class PageScrapper -{ - private string $url; - private string $contentMarker; - - public function __construct($url, $contentMarker = '
') - { - $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('//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 = []; - // - //safdsaf sdfdasf