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['description']}
+Бюджет
+ +Коммерция
+{$direction['description']}
+Бюджет
+ +Коммерция
+