From bbd706bd82c4c7f00b8c7a48e74b815d50e37cba Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 12 Mar 2024 09:32:57 +0300 Subject: [PATCH] add logging to faculty --- .gitea/workflows/php.yml | 36 +++++++++---------- Makefile | 7 +--- app/Helpers/PositionHelper.php | 7 ++++ .../admin/Catalog/FacultyController.php | 23 ++++++++---- .../2014_10_12_000000_create_users_table.php | 6 ++-- ...4_01_18_082250_create_admissions_table.php | 6 ++-- ...24_01_22_074748_create_documents_table.php | 6 ++-- ..._create_educational_institutions_table.php | 6 ++-- ...24_02_07_073254_create_faculties_table.php | 6 ++-- ..._02_08_074258_create_departments_table.php | 6 ++-- ...09_114154_create_education_forms_table.php | 4 +-- ...9_114154_create_education_levels_table.php | 4 +-- ...4_02_09_114155_create_directions_table.php | 18 +++++----- ..._075912_create_examination_types_table.php | 6 ++-- ...2_15_075912_create_subject_types_table.php | 6 ++-- ...024_02_15_075912_create_subjects_table.php | 6 ++-- ...913_create_entrance_examinations_table.php | 4 +-- ...064138_create_direction_profiles_table.php | 6 ++-- lang/ru/tooltips.php | 6 ++++ .../educational_institution/create.blade.php | 32 ++++++++++------- 20 files changed, 114 insertions(+), 87 deletions(-) diff --git a/.gitea/workflows/php.yml b/.gitea/workflows/php.yml index af48010..0caf2cc 100644 --- a/.gitea/workflows/php.yml +++ b/.gitea/workflows/php.yml @@ -59,21 +59,21 @@ jobs: - name: Check tests run: make test -# deploy: -# needs: build -# runs-on: ubuntu-latest -# steps: -# - name: deploy to test server -# uses: appleboy/ssh-action@v1.0.3 -# -# with: -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# password: ${{ secrets.PASSWORD }} -# port: ${{ secrets.PORT }} -# script: | -# cd /var/www/test-testabit/ -# git stash -# git pull --rebase -# git stash clear -# make setup-test + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: deploy to test server + uses: appleboy/ssh-action@v1.0.3 + + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + script: | + cd /var/www/www-root/data/www/testabit.mkgtu.ru + git stash + git pull --rebase + git stash clear + make setup-prod diff --git a/Makefile b/Makefile index 9be112e..4a7b1c2 100644 --- a/Makefile +++ b/Makefile @@ -15,13 +15,8 @@ setup: npm run build make ide-helper -setup-test: +setup-prod: composer install - cp -n .env.example .env - php artisan key:gen --ansi - touch database/database.sqlite - php artisan migrate:refresh - php artisan db:seed npm ci npm run build diff --git a/app/Helpers/PositionHelper.php b/app/Helpers/PositionHelper.php index f8ba61b..7e54a7f 100644 --- a/app/Helpers/PositionHelper.php +++ b/app/Helpers/PositionHelper.php @@ -4,6 +4,7 @@ namespace App\Helpers; use App\Models\Direction; use App\Models\Faculty; +use App\Models\EducationalInstitution; class PositionHelper { @@ -18,4 +19,10 @@ class PositionHelper $maxPosition = Direction::max('position'); return $maxPosition >= 254 ? 255 : $maxPosition + 1; } + + public static function educationalInstitution() + { + $maxPosition = EducationalInstitution::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } } diff --git a/app/Http/Controllers/admin/Catalog/FacultyController.php b/app/Http/Controllers/admin/Catalog/FacultyController.php index bfda604..35b3764 100644 --- a/app/Http/Controllers/admin/Catalog/FacultyController.php +++ b/app/Http/Controllers/admin/Catalog/FacultyController.php @@ -50,8 +50,10 @@ class FacultyController extends Controller $faculty->save(); Log::channel('app') - ->info('CREATE факультет {faculty} - user {user}', - ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated]); + ->info( + 'CREATE факультет {faculty} - user {user}', + ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated] + ); return redirect()->route('faculties.index'); } @@ -79,8 +81,15 @@ class FacultyController extends Controller $faculty->educational_institution_id = $validated['educational_institution_id']; Log::channel('app') - ->info('UPDATE факультет {faculty} - user {user}', - ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'oldData' => $oldData, 'newData' => $validated]); + ->info( + 'UPDATE факультет {faculty} - user {user}', + [ + 'user' => Auth::user()->name, + 'faculty' => $faculty->name, + 'oldData' => $oldData, + 'newData' => $validated + ] + ); $faculty->save(); return redirect()->route('faculties.index'); @@ -89,8 +98,10 @@ class FacultyController extends Controller public function destroy(Faculty $faculty): RedirectResponse { Log::channel('app') - ->info('DELETE факультет {faculty} - user {user}', - ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $faculty->toArray()]); + ->info( + 'DELETE факультет {faculty} - user {user}', + ['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $faculty->toArray()] + ); if ($faculty->departments()->exists()) { return back(); diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 750bc49..4be60a1 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->string('email')->unique(); + $table->string('name', 255); + $table->string('email', 255)->unique(); $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); + $table->string('password', 255); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2024_01_18_082250_create_admissions_table.php b/database/migrations/2024_01_18_082250_create_admissions_table.php index bf39cc3..e2c14a3 100644 --- a/database/migrations/2024_01_18_082250_create_admissions_table.php +++ b/database/migrations/2024_01_18_082250_create_admissions_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('admissions', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); - $table->integer('position'); + $table->string('slug', 255)->unique(); + $table->smallInteger('position'); $table->timestamps(); }); } diff --git a/database/migrations/2024_01_22_074748_create_documents_table.php b/database/migrations/2024_01_22_074748_create_documents_table.php index dd1421b..0b389cb 100644 --- a/database/migrations/2024_01_22_074748_create_documents_table.php +++ b/database/migrations/2024_01_22_074748_create_documents_table.php @@ -10,11 +10,11 @@ return new class extends Migration { Schema::create('documents', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->string('file_name')->nullable(); $table->text('description')->nullable(); - $table->string('url'); - $table->integer('position'); + $table->string('url', 255); + $table->smallInteger('position'); $table->foreignId('admission_id')->constrained('admissions'); $table->timestamps(); }); diff --git a/database/migrations/2024_02_06_062744_create_educational_institutions_table.php b/database/migrations/2024_02_06_062744_create_educational_institutions_table.php index a34ef5f..aa34494 100644 --- a/database/migrations/2024_02_06_062744_create_educational_institutions_table.php +++ b/database/migrations/2024_02_06_062744_create_educational_institutions_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('educational_institutions', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->string('slug'); + $table->string('name', 255)->unique(); + $table->string('slug', 255)->unique(); $table->text('description')->nullable(); - $table->integer('position'); + $table->smallInteger('position'); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_07_073254_create_faculties_table.php b/database/migrations/2024_02_07_073254_create_faculties_table.php index 055f47c..4c3a3e7 100644 --- a/database/migrations/2024_02_07_073254_create_faculties_table.php +++ b/database/migrations/2024_02_07_073254_create_faculties_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('faculties', function (Blueprint $table) { $table->id(); - $table->string('name')->unique(); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->integer('position'); - $table->string('slug')->unique(); + $table->smallInteger('position'); + $table->string('slug', 255)->unique(); $table->foreignId('educational_institution_id')->constrained('educational_institutions'); $table->timestamps(); }); diff --git a/database/migrations/2024_02_08_074258_create_departments_table.php b/database/migrations/2024_02_08_074258_create_departments_table.php index 5f5c51e..9e238ac 100644 --- a/database/migrations/2024_02_08_074258_create_departments_table.php +++ b/database/migrations/2024_02_08_074258_create_departments_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('departments', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->integer('position'); - $table->string('slug'); + $table->smallInteger('position'); + $table->string('slug', 255)->unique(); $table->foreignId('faculty_id')->constrained('faculties'); $table->timestamps(); }); diff --git a/database/migrations/2024_02_09_114154_create_education_forms_table.php b/database/migrations/2024_02_09_114154_create_education_forms_table.php index f5911b5..10e086b 100644 --- a/database/migrations/2024_02_09_114154_create_education_forms_table.php +++ b/database/migrations/2024_02_09_114154_create_education_forms_table.php @@ -10,9 +10,9 @@ return new class extends Migration { Schema::create('education_forms', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); + $table->string('slug', 255)->unique(); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_09_114154_create_education_levels_table.php b/database/migrations/2024_02_09_114154_create_education_levels_table.php index 708753d..256fdf3 100644 --- a/database/migrations/2024_02_09_114154_create_education_levels_table.php +++ b/database/migrations/2024_02_09_114154_create_education_levels_table.php @@ -10,9 +10,9 @@ return new class extends Migration { Schema::create('education_levels', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); + $table->string('slug', 255)->unique(); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_09_114155_create_directions_table.php b/database/migrations/2024_02_09_114155_create_directions_table.php index 8fe8385..68a7fdf 100644 --- a/database/migrations/2024_02_09_114155_create_directions_table.php +++ b/database/migrations/2024_02_09_114155_create_directions_table.php @@ -10,19 +10,19 @@ return new class extends Migration { Schema::create('directions', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->string('full_name'); + $table->string('name', 255)->unique(); + $table->string('full_name', 255); $table->text('description')->nullable(); - $table->string('code'); - $table->integer('position'); - $table->string('slug'); + $table->string('code', 255); + $table->smallInteger('position'); + $table->string('slug', 255)->unique(); $table->foreignId('department_id')->constrained('departments'); $table->foreignId('education_level_id')->constrained('education_levels'); $table->foreignId('education_form_id')->constrained('education_forms'); - $table->integer('budget_places'); - $table->integer('quota'); - $table->integer('paid_places'); - $table->integer('cost_paid_place'); + $table->smallInteger('budget_places'); + $table->smallInteger('quota'); + $table->smallInteger('paid_places'); + $table->smallInteger('cost_paid_place'); $table->float('period'); $table->timestamps(); }); diff --git a/database/migrations/2024_02_15_075912_create_examination_types_table.php b/database/migrations/2024_02_15_075912_create_examination_types_table.php index 4613728..5ef3389 100644 --- a/database/migrations/2024_02_15_075912_create_examination_types_table.php +++ b/database/migrations/2024_02_15_075912_create_examination_types_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('examination_types', function (Blueprint $table) { $table->id(); - $table->integer('position'); - $table->string('name'); + $table->smallInteger('position'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); + $table->string('slug', 255)->unique(); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_15_075912_create_subject_types_table.php b/database/migrations/2024_02_15_075912_create_subject_types_table.php index 5d3aa25..2fc2732 100644 --- a/database/migrations/2024_02_15_075912_create_subject_types_table.php +++ b/database/migrations/2024_02_15_075912_create_subject_types_table.php @@ -10,10 +10,10 @@ return new class extends Migration { Schema::create('subject_types', function (Blueprint $table) { $table->id(); - $table->integer('position'); - $table->string('name'); + $table->smallInteger('position'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); + $table->string('slug', 255)->unique(); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_15_075912_create_subjects_table.php b/database/migrations/2024_02_15_075912_create_subjects_table.php index d36c7b8..ed2635a 100644 --- a/database/migrations/2024_02_15_075912_create_subjects_table.php +++ b/database/migrations/2024_02_15_075912_create_subjects_table.php @@ -13,10 +13,10 @@ return new class extends Migration { Schema::create('subjects', function (Blueprint $table) { $table->id(); - $table->integer('position'); - $table->string('name'); + $table->smallInteger('position'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); + $table->string('slug', 255)->unique(); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php b/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php index a18dcf1..4a24fba 100644 --- a/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php +++ b/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php @@ -13,8 +13,8 @@ return new class extends Migration $table->foreignId('examination_type_id')->constrained('examination_types'); $table->foreignId('direction_id')->constrained('directions'); $table->foreignId('subject_id')->constrained('subjects'); - $table->integer('scores'); - $table->integer('position'); + $table->tinyInteger('scores'); + $table->smallInteger('position'); $table->foreignId('subject_type_id')->constrained('subject_types'); $table->timestamps(); }); diff --git a/database/migrations/2024_02_26_064138_create_direction_profiles_table.php b/database/migrations/2024_02_26_064138_create_direction_profiles_table.php index d2f24cf..6964c13 100644 --- a/database/migrations/2024_02_26_064138_create_direction_profiles_table.php +++ b/database/migrations/2024_02_26_064138_create_direction_profiles_table.php @@ -13,10 +13,10 @@ return new class extends Migration { Schema::create('direction_profiles', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('name', 255)->unique(); $table->text('description')->nullable(); - $table->string('slug'); - $table->string('position'); + $table->string('slug', 255)->unique(); + $table->smallInteger('position'); $table->timestamps(); }); } diff --git a/lang/ru/tooltips.php b/lang/ru/tooltips.php index f17ea14..530f8ab 100644 --- a/lang/ru/tooltips.php +++ b/lang/ru/tooltips.php @@ -34,4 +34,10 @@ return [ 'scores' => 'Поле "Кол-во баллов" указывает на привязку вступительного испытания к Кол-ву баллов', 'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте', ], + 'educational_institutions' => [ + 'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте', + 'name' => 'Поле "Название" должно быть уникальным для отображения на сайте', + 'description' => 'Поле "Описание" может быть пустым для отображения на сайте', + 'slug' => 'Поле "URL" нужно для отображения в браузере' + ], ]; diff --git a/resources/views/admin/catalog/educational_institution/create.blade.php b/resources/views/admin/catalog/educational_institution/create.blade.php index c1b4992..53ec8ee 100644 --- a/resources/views/admin/catalog/educational_institution/create.blade.php +++ b/resources/views/admin/catalog/educational_institution/create.blade.php @@ -4,50 +4,58 @@

Создать учебное заведение

- {{ Form::open(['url' => route('educational_institutions.store'), 'method' => 'POST', 'class' => '']) }} + {{ Form::open(['url' => route('educational_institutions.store'), 'method' => 'POST', 'class' => 'needs-validation', 'novalidate']) }}
- {{ Form::label('position', 'Позиция') }} + {{ Form::label('position', 'Позиция', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.position')]) }} + *
- {{ Form::text('position', '', ['class' => 'form-control']) }} + {{ Form::text('position', PositionHelper::educationalInstitution(), ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.position'), 'required']) }} +
+ Поле "Позиция" обязательно! +
-
+
@if ($errors->any()) {{ $errors->first('position') }} @endif
- {{ Form::label('name', 'Название') }} + {{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name')]) }} + *
- {{ Form::text('name', '', ['class' => 'form-control']) }} + {{ Form::text('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name'), 'required']) }} +
+ Поле "Название" обязательно! +
-
+
@if ($errors->any()) {{ $errors->first('name') }} @endif
- {{ Form::label('description', 'Описание') }} + {{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }}
- {{ Form::text('description', '', ['class' => 'form-control']) }} + {{ Form::text('description', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }}
-
+
@if ($errors->any()) {{ $errors->first('description') }} @endif
- {{ Form::label('slug', 'URL') }} + {{ Form::label('slug', 'URL', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.slug')]) }}
{{ Form::text('slug', '', ['class' => 'form-control']) }}
-
+
@if ($errors->any()) {{ $errors->first('slug') }} @endif