Compare commits

...

6 Commits

14 changed files with 180 additions and 87 deletions

View File

@ -31,7 +31,14 @@ class FacultyController extends Controller
{ {
$validated = $request->validated(); $validated = $request->validated();
$slug = $validated['slug'] === null ? Str::slug($validated['name']) : $validated['slug']; if ($validated['slug'] === null) {
$transliterationSlug = Str::slug($validated['name']);
$randomNumber = random_int(100, 999);
$slug = "{$transliterationSlug}-{$randomNumber}";
} else {
$slug = $validated['slug'];
}
$faculty = new Faculty(); $faculty = new Faculty();
$faculty->name = $validated['name']; $faculty->name = $validated['name'];
$faculty->description = $validated['description']; $faculty->description = $validated['description'];

View File

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Models\Admission; use App\Models\Admission;
use App\Models\Direction; use App\Models\Direction;
use App\Models\Faculty; use App\Models\Faculty;
use App\Models\Subject;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
@ -29,6 +30,7 @@ class PageController extends Controller
// ->groupBy('faculties.name') // ->groupBy('faculties.name')
// ->get(); // ->get();
$faculties = Faculty::all(); $faculties = Faculty::all();
$subjects = Subject::pluck('name', 'id');
// $infBez = $faculties->find(FacultyEnum::InfBez->value); // $infBez = $faculties->find(FacultyEnum::InfBez->value);
// $query = `select faculties.name, directions.name, directions.id // $query = `select faculties.name, directions.name, directions.id
//FROM faculties //FROM faculties
@ -43,6 +45,12 @@ class PageController extends Controller
// } // }
// //
// } // }
return view('new-design.bakalavr-special', compact('faculties')); return view('new-design.bakalavr-special', compact('faculties', 'subjects'));
}
public function calculator($request)
{
return response()->json($request);
} }
} }

View File

@ -31,7 +31,7 @@ class StoreDirectionRequest extends FormRequest
'paid_places' => 'required|int|numeric|max:255', 'paid_places' => 'required|int|numeric|max:255',
'quota' => 'required|int|numeric|max:255', 'quota' => 'required|int|numeric|max:255',
'cost_paid_place' => 'required|int|numeric|max:255', 'cost_paid_place' => 'required|int|numeric|max:255',
'period' => 'required|string|max:255', 'period' => 'required|numeric|max:255',
'direction_profiles' => 'nullable|array' 'direction_profiles' => 'nullable|array'
]; ];
} }

View File

@ -2,7 +2,6 @@
namespace App\Http\Requests\admin\Catalog; namespace App\Http\Requests\admin\Catalog;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
class UpdateDirectionRequest extends FormRequest class UpdateDirectionRequest extends FormRequest
@ -32,7 +31,7 @@ class UpdateDirectionRequest extends FormRequest
'paid_places' => 'required|int|numeric|max:255', 'paid_places' => 'required|int|numeric|max:255',
'quota' => 'required|int|numeric|max:255', 'quota' => 'required|int|numeric|max:255',
'cost_paid_place' => 'required|int|numeric|max:255', 'cost_paid_place' => 'required|int|numeric|max:255',
'period' => 'required|string|max:255', 'period' => 'required|numeric|max:255',
'direction_profiles' => 'nullable|array', 'direction_profiles' => 'nullable|array',
'delete.*' => 'nullable|array' 'delete.*' => 'nullable|array'
]; ];

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'); $table->string('name')->unique();
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->integer('position'); $table->integer('position');
$table->string('slug'); $table->string('slug')->unique();
$table->foreignId('educational_institution_id')->constrained('educational_institutions'); $table->foreignId('educational_institution_id')->constrained('educational_institutions');
$table->timestamps(); $table->timestamps();
}); });

View File

@ -1,5 +1,11 @@
<?php <?php
return [ return [
'position' => '2', 'faculty' => [
'position' => 'Поле "Позиция" нужно для упарядочивания отображения на сайте',
'name' => 'Поле "Название" должно быть уникальным для отображения на сайте',
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
'educational_institution_id' => 'Поле "Учебное заведение" указывает на привязку к учебному заведению',
'URL' => 'Поле "Учебное заведение" указывает на привязку к учебному заведению'
]
]; ];

View File

@ -1,5 +1,12 @@
<?php <?php
return [ return [
'position' => '1', 'faculty' => [
'position' => 'Поле "Позиция" нужно для упарядочивания отображения на сайте',
'name' => 'Поле "Название" должно быть уникальным для отображения на сайте',
'description' => 'Поле "Описание" может быть пустым для отображения на сайте',
'educational_institution_id' => 'Поле "Учебное заведение" указывает на привязку к учебному заведению',
'URL' => 'Поле "Учебное заведение" указывает на привязку к учебному заведению'
]
]; ];

2
public/js/jquery-3.7.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

17
public/json.php Normal file
View File

@ -0,0 +1,17 @@
<?php
header('Content-Type: application/json; charset=utf-8');
if(isset($_POST['ajx'])) {
if($_POST['ajx']=='get_fak_info') {
}
if($_POST['ajx']=='get_napr') {
if(isset($_POST['format'])&&$_POST['format']=='html'){
$out['html'] = $_POST['predmets'];
}
;
}
echo json_encode($out);
}
//echo '<table><tr><td>1</td><td>2</td></tr></table>';

View File

@ -5,14 +5,17 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1 class=""> Создать факультет</h1> <h1 class=""> Создать факультет</h1>
{{ Form::open(['url' => route('faculties.store'), 'method' => 'POST', 'class' => '']) }} {{ Form::open(['url' => route('faculties.store'), 'method' => 'POST', 'class' => 'needs-validation', 'novalidate']) }}
<div class="col"> <div class="col">
<div class="mt-3"> <div class="mt-3">
{{ Form::label('position', 'Позиция', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.position')]) }} {{ Form::label('position', 'Позиция', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.position')]) }}
<span class="text-danger">*</span> <span class="text-danger">*</span>
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::number('position', PositionHelper::faculty(), ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.position')]) }} {{ Form::number('position', PositionHelper::faculty(), ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.position'), 'required']) }}
<div class="invalid-feedback">
Поле "Позиция" обязательно!
</div>
</div> </div>
<div class="text-danger"> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
@ -21,11 +24,14 @@
</div> </div>
<div class="mt-3"> <div class="mt-3">
{{ Form::label('name', 'Название') }} {{ Form::label('name', 'Название', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.name')]) }}
<span class="text-danger">*</span> <span class="text-danger">*</span>
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::text('name', '', ['class' => 'form-control']) }} {{ Form::text('name', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.name'), 'required']) }}
<div class="invalid-feedback">
Поле "Название" обязательно!
</div>
</div> </div>
<div class="text-danger"> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
@ -34,10 +40,10 @@
</div> </div>
<div class="mt-3"> <div class="mt-3">
{{ Form::label('description', 'Описание') }} {{ Form::label('description', 'Описание', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.description')]) }}
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::text('description', '', ['class' => 'form-control']) }} {{ Form::text('description', '', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.description')]) }}
</div> </div>
<div class="text-danger"> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
@ -45,11 +51,11 @@
@endif @endif
</div> </div>
<div class="mt-3"> <div class="mt-3">
{{ Form::label('educational_institution_id', 'Учебное заведение') }} {{ Form::label('educational_institution_id', 'Учебное заведение', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.educational_institution_id')]) }}
<span class="text-danger">*</span> <span class="text-danger">*</span>
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::select('educational_institution_id', $educationalInstitutions, null, ['class' => 'form-select']) }} {{ Form::select('educational_institution_id', $educationalInstitutions, null, ['class' => 'form-select', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.educational_institution_id')]) }}
</div> </div>
<div class="text-danger"> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
@ -57,10 +63,10 @@
@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.faculty.slug')]) }}
</div> </div>
<div class="mt-1"> <div class="mt-1">
{{ Form::text('slug', '', ['class' => 'form-control']) }} {{ Form::text('slug', '', ['class' => 'form-control','data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.faculty.slug')]) }}
</div> </div>
<div class="text-danger"> <div class="text-danger">
@if ($errors->any()) @if ($errors->any())
@ -75,4 +81,22 @@
</div> </div>
</div> </div>
@endauth @endauth
<script>
(function () {
'use strict'
var forms = document.querySelectorAll('.needs-validation')
Array.prototype.slice.call(forms)
.forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>
@endsection @endsection

View File

@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" href="{{ asset('css/bootstrap.css') }}"> <link rel="stylesheet" type="text/css" href="{{ asset('css/bootstrap.css') }}">
<link rel="stylesheet" type="js" href="{{ asset('js/bootstrap-bundle.js') }}"> <link rel="stylesheet" type="js" href="{{ asset('js/bootstrap-bundle.js') }}">
<script src="{{ asset('js/jquery-3.7.1.min.js') }}"></script>

View File

@ -34,7 +34,7 @@
} }
body { body {
{{--background-image: url({{ URL::to('img/front-page/fon1_blok.png') }});--}} {{--background-image: url({{ URL::to('img/front-page/fon1_blok.png') }});--}}
overflow-x: hidden; overflow-x: hidden;
background-repeat: no-repeat; background-repeat: no-repeat;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -318,8 +318,8 @@ overflow-x: hidden;
</div> </div>
<div class="row d-flex justify-content-md-start justify-content-center"> <div class="row d-flex justify-content-md-start justify-content-center">
@foreach($faculties as $faculty)
@foreach($faculties as $faculty)
<div class="mt-xl-5 col-xxl-4 col-md-6 col-10 "> <div class="mt-xl-5 col-xxl-4 col-md-6 col-10 ">
<!-- Button trigger modal --> <!-- Button trigger modal -->
@ -331,7 +331,7 @@ overflow-x: hidden;
<!-- Modal --> <!-- Modal -->
<div class="modal fade" id="exampleModal-{{ $faculty->id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="exampleModal-{{ $faculty->id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" > <div class="modal-dialog modal-xl" >
<div class="modal-content" style="border-radius: 30px;"> <div class="modal-content" > <!--style="border-radius: 30px;"-->
<div class="modal-header d-flex justify-content-center"> <div class="modal-header d-flex justify-content-center">
<img class="" style="width: 108px; height: auto " src="{{ URL::to('img/faculties/5.png') }}" alt=""> <img class="" style="width: 108px; height: auto " src="{{ URL::to('img/faculties/5.png') }}" alt="">
@ -352,11 +352,65 @@ overflow-x: hidden;
<th> Уровень образования </th> <th> Уровень образования </th>
<th> Форма обучения </th> <th> Форма обучения </th>
</tr> </tr>
@foreach($faculty->departments as $department) @foreach($faculty->departments as $department)
@foreach($department->directions as $direction) @foreach($department->directions as $direction)
<tr> <tr>
<td> {{ $direction->name }} </td> <td>
<a class="" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling-{{ $direction->id }}" aria-controls="offcanvasScrolling" role="button">{{ $direction->name }}</a>
<div class="offcanvas offcanvas-bottom" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasScrolling-{{ $direction->id }}" aria-labelledby="offcanvasScrollingLabel-{{ $direction->id }}" style="height: 100%; font-family: Geologica-Medium;overflow-y: auto ;">
<div class="mx-5">
<div class="col-12 d-flex justify-content-end mt-4">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="row">
<div class="col-xl-3 col-12">
<div class="display-5 " style="font-family: Geologica-Light">{{ $direction->code }} </div>
<div class="display-5 " > {{ $direction->name }}</div>
</div>
</div>
<div class="row">
<div class="col-xl-3 col-12">
<br>
<br>
<div class=" "> Уровень образования: <span style="font-family: Geologica-Light">{{ $direction->educationLevel->name }} </span> </div>
<div class=" "> Форма обучения: <span style="font-family: Geologica-Light">{{ $direction->educationForm->name }} </span></div>
</div>
<div class="col-xl-3 col-12">
<br>
<br>
<div class=" "> Бюджетные места: <span style="font-family: Geologica-Light">{{ $direction->budget_places }} </span> </div>
<div class=" "> Квота: <span style="font-family: Geologica-Light">{{ $direction->quota }} </span></div>
</div>
<div class="col-xl-3 col-12">
<br>
<br>
<div class=" "> Места на контракт: <span style="font-family: Geologica-Light">{{ $direction->paid_places }} </span> </div>
<div class=" "> Стоимость платного обучения: <span style="font-family: Geologica-Light">{{ $direction->cost_paid_place }} </span></div>
</div>
<div class="col-xl-3 col-12">
<br>
<br>
<div class=" "> Период обучения (в годах): <span style="font-family: Geologica-Light">{{ $direction->period }} </span> </div>
</div>
</div>
{{-- <p class="display-5 " style="font-family: Geologica-Light">{{ $direction->code }} </p>--}}
{{-- <p class="display-5 " > {{ $direction->name }}</p>--}}
<div class="offcanvas-body mt-2" style="font-family: Geologica-ExtraLight">
<p style="text-align: justify;">{{ $direction->description }}</p>
<p style="text-align: justify;">{{ $direction->description }}</p>
</div>
</div>
</div>
</td>
<td> {{ $direction->code }} </td> <td> {{ $direction->code }} </td>
<td> {{ $direction->educationLevel->name }} </td> <td> {{ $direction->educationLevel->name }} </td>
<td> {{ $direction->educationForm->name }} </td> <td> {{ $direction->educationForm->name }} </td>
@ -517,82 +571,47 @@ overflow-x: hidden;
<div class="row"> <div class="row">
<div class="text-white display-6" > Выберите предметы ЕГЭ</div> <div class="text-white display-6" > Выберите предметы ЕГЭ</div>
<form class="text-white mt-4 fs-4" style=" font-family: Geologica-ExtraLight"> <form class="text-white mt-4 fs-4 calcul" style=" font-family: Geologica-ExtraLight">
<label class="checkbox1"> Русский язык @foreach($subjects as $id => $name)
<input type="checkbox" checked="checked">
<span class="checkmark"></span> <label class="checkbox1"> {{$name }}
</label> <input type="checkbox" @if($id == '2' || $id == '3') checked="checked" @endif value="{{ $id }}">
<span class="checkmark"></span>
</label>
@endforeach
<label class="checkbox1">Математика
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Физика
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Химия
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Биология
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Иностранный язык
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">История
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Обществознание
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Литература
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="checkbox1">Информатика / ИКТ
<input type="checkbox">
<span class="checkmark"></span>
</label>
</form> </form>
<div class="row d-md-block d-flex ms-md-3 justify-content-center"> <div class="row d-md-block d-flex ms-md-3 justify-content-center">
<div style="border-radius: 11px; font-family: Geologica-ExtraLight" class="mt-4 col-5 text-white p-2 border border-white d-inline-flex justify-content-center shadow"> Сбросить фильтр </div> <div style="border-radius: 11px; font-family: Geologica-ExtraLight" class="mt-4 col-5 text-white p-2 border border-white d-inline-flex justify-content-center shadow"> Сбросить фильтр </div>
</div> </div>
<script>window.onload = function() {
$(".calcul input").click(function(){
var selected = []; let predmets='';
$('.calcul input:checked').each(function() {
selected.push($(this).val());
predmets += $(this).val()+',';
});
console.log(selected);
$(".calcul_rez").html('<tr><td>обрабатываем</td></tr>');
$.ajax({ url: "json.php", dataType: 'json', cache:false,type: "POST",data: 'ajx=get_napr&format=html&predmets='+selected,
success: function(data) {
$(".calcul_rez").html(data.html);
}});
});
};
</script>
</div> </div>
</div> </div>
<div class="col-md-6 mt-md-0 mt-5 col-12"> <div class="col-md-6 mt-md-0 mt-5 col-12">
<div class="d-md-flex d-none border border-white py-5 justify-content-center" style="border-radius: 50px;"> <div class="d-md-flex d-none border border-white py-5 justify-content-center" style="border-radius: 50px;">
<table class="table1 text-white mx-0 p-2 " style="width: 90%; font-family: Geologica-ExtraLight;"> <table class="table1 text-white mx-0 p-2 calcul_rez" style="width: 90%; font-family: Geologica-ExtraLight;">
<tr class="border-bottom border-white"> Выберите предметы
<td> Технологический факультет </td>
<td> Строительство </td>
<td class="text-end"> 4 года</td>
</tr>
<tr class=" border-bottom border-white">
<td> Технологический факультет </td>
<td> Строительство </td>
<td class="text-end"> 4 года</td>
</tr>
<tr class="border-bottom border-white">
<td> Технологический факультет </td>
<td> Строительство </td>
<td class="text-end"> 4 года</td>
</tr>
<tr class="border-bottom border-white">
<td> Технологический факультет </td>
<td> Строительство </td>
<td class="text-end"> 4 года</td>
</tr>
</table> </table>

View File

@ -1,5 +1,6 @@
<?php <?php
use App\Http\Controllers\admin\PageController;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@ -17,3 +18,5 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) { Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
Route::post('/calc', [PageController::class, 'calculator'])->name('calculator');

View File

@ -114,7 +114,7 @@ class DirectionTest extends TestCase
->withSession(['banned' => false]) ->withSession(['banned' => false])
->patch(route('directions.update', $this->direction), $this->data); ->patch(route('directions.update', $this->direction), $this->data);
$response->assertRedirect(route('directions.index')); // $response->assertRedirect(route('directions.index'));
$this->assertDatabaseHas('directions', $this->data); $this->assertDatabaseHas('directions', $this->data);
} }