add logging to faculty
Tests & Lint & Deploy to Railway / deploy (push) Blocked by required conditions Details
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Has been cancelled Details

This commit is contained in:
aslan 2024-03-12 09:32:57 +03:00
parent 3c37c2b903
commit bbd706bd82
20 changed files with 114 additions and 87 deletions

View File

@ -59,21 +59,21 @@ jobs:
- name: Check tests - name: Check tests
run: make test run: make test
# deploy: deploy:
# needs: build needs: build
# runs-on: ubuntu-latest runs-on: ubuntu-latest
# steps: steps:
# - name: deploy to test server - name: deploy to test server
# uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
#
# with: with:
# host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
# username: ${{ secrets.USERNAME }} username: ${{ secrets.USERNAME }}
# password: ${{ secrets.PASSWORD }} password: ${{ secrets.PASSWORD }}
# port: ${{ secrets.PORT }} port: ${{ secrets.PORT }}
# script: | script: |
# cd /var/www/test-testabit/ cd /var/www/www-root/data/www/testabit.mkgtu.ru
# git stash git stash
# git pull --rebase git pull --rebase
# git stash clear git stash clear
# make setup-test make setup-prod

View File

@ -15,13 +15,8 @@ setup:
npm run build npm run build
make ide-helper make ide-helper
setup-test: setup-prod:
composer install 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 ci
npm run build npm run build

View File

@ -4,6 +4,7 @@ namespace App\Helpers;
use App\Models\Direction; use App\Models\Direction;
use App\Models\Faculty; use App\Models\Faculty;
use App\Models\EducationalInstitution;
class PositionHelper class PositionHelper
{ {
@ -18,4 +19,10 @@ class PositionHelper
$maxPosition = Direction::max('position'); $maxPosition = Direction::max('position');
return $maxPosition >= 254 ? 255 : $maxPosition + 1; return $maxPosition >= 254 ? 255 : $maxPosition + 1;
} }
public static function educationalInstitution()
{
$maxPosition = EducationalInstitution::max('position');
return $maxPosition >= 254 ? 255 : $maxPosition + 1;
}
} }

View File

@ -50,8 +50,10 @@ class FacultyController extends Controller
$faculty->save(); $faculty->save();
Log::channel('app') Log::channel('app')
->info('CREATE факультет {faculty} - user {user}', ->info(
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated]); 'CREATE факультет {faculty} - user {user}',
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $validated]
);
return redirect()->route('faculties.index'); return redirect()->route('faculties.index');
} }
@ -79,8 +81,15 @@ class FacultyController extends Controller
$faculty->educational_institution_id = $validated['educational_institution_id']; $faculty->educational_institution_id = $validated['educational_institution_id'];
Log::channel('app') Log::channel('app')
->info('UPDATE факультет {faculty} - user {user}', ->info(
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'oldData' => $oldData, 'newData' => $validated]); 'UPDATE факультет {faculty} - user {user}',
[
'user' => Auth::user()->name,
'faculty' => $faculty->name,
'oldData' => $oldData,
'newData' => $validated
]
);
$faculty->save(); $faculty->save();
return redirect()->route('faculties.index'); return redirect()->route('faculties.index');
@ -89,8 +98,10 @@ class FacultyController extends Controller
public function destroy(Faculty $faculty): RedirectResponse public function destroy(Faculty $faculty): RedirectResponse
{ {
Log::channel('app') Log::channel('app')
->info('DELETE факультет {faculty} - user {user}', ->info(
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $faculty->toArray()]); 'DELETE факультет {faculty} - user {user}',
['user' => Auth::user()->name, 'faculty' => $faculty->name, 'data' => $faculty->toArray()]
);
if ($faculty->departments()->exists()) { if ($faculty->departments()->exists()) {
return back(); return back();

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255);
$table->string('email')->unique(); $table->string('email', 255)->unique();
$table->timestamp('email_verified_at')->nullable(); $table->timestamp('email_verified_at')->nullable();
$table->string('password'); $table->string('password', 255);
$table->rememberToken(); $table->rememberToken();
$table->timestamps(); $table->timestamps();
}); });

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('admissions', function (Blueprint $table) { Schema::create('admissions', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->integer('position'); $table->smallInteger('position');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -10,11 +10,11 @@ return new class extends Migration
{ {
Schema::create('documents', function (Blueprint $table) { Schema::create('documents', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->string('file_name')->nullable(); $table->string('file_name')->nullable();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('url'); $table->string('url', 255);
$table->integer('position'); $table->smallInteger('position');
$table->foreignId('admission_id')->constrained('admissions'); $table->foreignId('admission_id')->constrained('admissions');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('educational_institutions', function (Blueprint $table) { Schema::create('educational_institutions', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->integer('position'); $table->smallInteger('position');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('faculties', function (Blueprint $table) { Schema::create('faculties', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name')->unique(); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->integer('position'); $table->smallInteger('position');
$table->string('slug')->unique(); $table->string('slug', 255)->unique();
$table->foreignId('educational_institution_id')->constrained('educational_institutions'); $table->foreignId('educational_institution_id')->constrained('educational_institutions');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('departments', function (Blueprint $table) { Schema::create('departments', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->integer('position'); $table->smallInteger('position');
$table->string('slug'); $table->string('slug', 255)->unique();
$table->foreignId('faculty_id')->constrained('faculties'); $table->foreignId('faculty_id')->constrained('faculties');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -10,9 +10,9 @@ return new class extends Migration
{ {
Schema::create('education_forms', function (Blueprint $table) { Schema::create('education_forms', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -10,9 +10,9 @@ return new class extends Migration
{ {
Schema::create('education_levels', function (Blueprint $table) { Schema::create('education_levels', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -10,19 +10,19 @@ return new class extends Migration
{ {
Schema::create('directions', function (Blueprint $table) { Schema::create('directions', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->string('full_name'); $table->string('full_name', 255);
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('code'); $table->string('code', 255);
$table->integer('position'); $table->smallInteger('position');
$table->string('slug'); $table->string('slug', 255)->unique();
$table->foreignId('department_id')->constrained('departments'); $table->foreignId('department_id')->constrained('departments');
$table->foreignId('education_level_id')->constrained('education_levels'); $table->foreignId('education_level_id')->constrained('education_levels');
$table->foreignId('education_form_id')->constrained('education_forms'); $table->foreignId('education_form_id')->constrained('education_forms');
$table->integer('budget_places'); $table->smallInteger('budget_places');
$table->integer('quota'); $table->smallInteger('quota');
$table->integer('paid_places'); $table->smallInteger('paid_places');
$table->integer('cost_paid_place'); $table->smallInteger('cost_paid_place');
$table->float('period'); $table->float('period');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('examination_types', function (Blueprint $table) { Schema::create('examination_types', function (Blueprint $table) {
$table->id(); $table->id();
$table->integer('position'); $table->smallInteger('position');
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -10,10 +10,10 @@ return new class extends Migration
{ {
Schema::create('subject_types', function (Blueprint $table) { Schema::create('subject_types', function (Blueprint $table) {
$table->id(); $table->id();
$table->integer('position'); $table->smallInteger('position');
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -13,10 +13,10 @@ return new class extends Migration
{ {
Schema::create('subjects', function (Blueprint $table) { Schema::create('subjects', function (Blueprint $table) {
$table->id(); $table->id();
$table->integer('position'); $table->smallInteger('position');
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -13,8 +13,8 @@ return new class extends Migration
$table->foreignId('examination_type_id')->constrained('examination_types'); $table->foreignId('examination_type_id')->constrained('examination_types');
$table->foreignId('direction_id')->constrained('directions'); $table->foreignId('direction_id')->constrained('directions');
$table->foreignId('subject_id')->constrained('subjects'); $table->foreignId('subject_id')->constrained('subjects');
$table->integer('scores'); $table->tinyInteger('scores');
$table->integer('position'); $table->smallInteger('position');
$table->foreignId('subject_type_id')->constrained('subject_types'); $table->foreignId('subject_type_id')->constrained('subject_types');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -13,10 +13,10 @@ return new class extends Migration
{ {
Schema::create('direction_profiles', function (Blueprint $table) { Schema::create('direction_profiles', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name', 255)->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('slug'); $table->string('slug', 255)->unique();
$table->string('position'); $table->smallInteger('position');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@ -34,4 +34,10 @@ return [
'scores' => 'Поле "Кол-во баллов" указывает на привязку вступительного испытания к Кол-ву баллов', 'scores' => 'Поле "Кол-во баллов" указывает на привязку вступительного испытания к Кол-ву баллов',
'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте', 'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте',
], ],
'educational_institutions' => [
'position' => 'Поле "Позиция" нужно для упорядочивания отображения на сайте',
'name' => 'Поле "Название" должно быть уникальным для отображения на сайте',
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
'slug' => 'Поле "URL" нужно для отображения в браузере'
],
]; ];

View File

@ -4,50 +4,58 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1 class=""> Создать учебное заведение</h1> <h1 class=""> Создать учебное заведение</h1>
{{ Form::open(['url' => route('educational_institutions.store'), 'method' => 'POST', 'class' => '']) }} {{ Form::open(['url' => route('educational_institutions.store'), 'method' => 'POST', 'class' => 'needs-validation', 'novalidate']) }}
<div class="col"> <div class="col">
<div> <div>
{{ Form::label('position', 'Позиция') }} {{ Form::label('position', 'Позиция', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.position')]) }}
<span class="text-danger">*</span>
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ 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']) }}
<div class="invalid-feedback">
Поле "Позиция" обязательно!
</div> </div>
<div> </div>
<div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('position') }} {{ $errors->first('position') }}
@endif @endif
</div> </div>
<div> <div>
{{ Form::label('name', 'Название') }} {{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name')]) }}
<span class="text-danger">*</span>
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }} {{ Form::text('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.name'), 'required']) }}
<div class="invalid-feedback">
Поле "Название" обязательно!
</div> </div>
<div> </div>
<div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('name') }} {{ $errors->first('name') }}
@endif @endif
</div> </div>
<div> <div>
{{ Form::label('description', 'Описание') }} {{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }}
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ Form::text('description', '', ['class' => 'form-control']) }} {{ Form::text('description', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.description')]) }}
</div> </div>
<div> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('description') }} {{ $errors->first('description') }}
@endif @endif
</div> </div>
<div class="mt-3"> <div class="mt-3">
{{ Form::label('slug', 'URL') }} {{ Form::label('slug', 'URL', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.educational_institutions.slug')]) }}
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::text('slug', '', ['class' => 'form-control']) }} {{ Form::text('slug', '', ['class' => 'form-control']) }}
</div> </div>
<div> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('slug') }} {{ $errors->first('slug') }}
@endif @endif