Commit 96681864eeb520fc2c9adf4507da38610e460119

Authored by Андрей Ларионов
1 parent 180e53f582

Справочник образование и программы образования

Showing 9 changed files with 176 additions and 6 deletions Side-by-side Diff

app/Http/Controllers/Admin/EducationController.php
... ... @@ -4,7 +4,9 @@ namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
6 6 use App\Http\Requests\EducationRequest;
  7 +use App\Http\Requests\ProgramEducationRequest;
7 8 use App\Models\Education;
  9 +use App\Models\ProgramEducation;
8 10 use Illuminate\Http\Request;
9 11 use Illuminate\Support\Facades\Storage;
10 12  
... ... @@ -68,8 +70,14 @@ class EducationController extends Controller
68 70 */
69 71 public function edit(Education $education)
70 72 {
  73 + $program1 = ProgramEducation::query()->where('education_id', '=', $education->id)
  74 + ->where('level', '=', '1')->get();
  75 + $program2 = ProgramEducation::query()->where('education_id', '=', $education->id)
  76 + ->where('level', '=', '2')->get();
  77 + $program3 = ProgramEducation::query()->where('education_id', '=', $education->id)
  78 + ->where('level', '=', '3')->get();
71 79  
72   - return view('admin.education.edit', compact('education'));
  80 + return view('admin.education.edit', compact('education', 'program1', 'program2', 'program3'));
73 81 }
74 82  
75 83 /**
... ... @@ -104,4 +112,17 @@ class EducationController extends Controller
104 112 $education->update(['is_remove' => 1]);
105 113 return redirect()->route('admin.education.index');
106 114 }
  115 +
  116 + public function add_program(Education $education, int $level) {
  117 + $id_education = $education->id;
  118 + return view('admin.education.program', compact('id_education', 'level'));
  119 + }
  120 +
  121 + public function store_program(ProgramEducationRequest $request) {
  122 + $education = $request->education_id;
  123 + ProgramEducation::create($request->all());
  124 +
  125 + return redirect()->route('admin.education.edit', ['education' => $education]);
  126 + }
  127 +
107 128 }
app/Http/Requests/JobTitlesRequest.php
... ... @@ -27,7 +27,7 @@ class JobTitlesRequest extends FormRequest
27 27 'name' => [
28 28 'required',
29 29 'min:3',
30   - 'max:100',
  30 + 'max:255',
31 31 ],
32 32 'parent_id' => [
33 33 'numeric',
app/Http/Requests/ProgramEducationRequest.php
... ... @@ -0,0 +1,34 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Requests;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class ProgramEducationRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 +
  19 + /**
  20 + * Get the validation rules that apply to the request.
  21 + *
  22 + * @return array<string, mixed>
  23 + */
  24 + public function rules()
  25 + {
  26 + return [
  27 + 'name' => [
  28 + 'required',
  29 + 'min:3',
  30 + 'max:255',
  31 + ],
  32 + ];
  33 + }
  34 +}
app/Models/ProgramEducation.php
... ... @@ -8,4 +8,14 @@ use Illuminate\Database\Eloquent\Model;
8 8 class ProgramEducation extends Model
9 9 {
10 10 use HasFactory;
  11 +
  12 + protected $fillable = [
  13 + 'id',
  14 + 'name',
  15 + 'education_id',
  16 + 'text',
  17 + 'email',
  18 + 'telephone',
  19 + 'level',
  20 + ];
11 21 }
database/migrations/2023_10_16_083120_create_program_education_table.php
... ... @@ -20,7 +20,7 @@ return new class extends Migration
20 20 $table->string('name', 255)->nullable(false);
21 21 $table->text('text')->nullable();
22 22 $table->string('email', 255)->nullable();
23   - $table->string('telephone', 255);
  23 + $table->string('telephone', 255)->nullable();
24 24 $table->timestamps();
25 25 });
26 26 }
resources/views/admin/education/form.blade.php
... ... @@ -59,7 +59,7 @@
59 59  
60 60 <label class="block text-sm">
61 61 <span class="text-gray-700 dark:text-gray-400">Текст</span>
62   - <textarea class="form-control ckeditor" name="text" placeholder="Текст (html)" required
  62 + <textarea class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-textarea focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray ckeditor" name="text" placeholder="Текст (html)" required
63 63 rows="10">{{ old('text') ?? $education->text ?? '' }}</textarea>
64 64 @error('text')
65 65 <span class="text-xs text-red-600 dark:text-red-400">
... ... @@ -84,6 +84,63 @@
84 84 @endisset
85 85 </label><br>
86 86  
  87 +
  88 + @isset($education)
  89 + <div class="tabs">
  90 + <input type="radio" name="tab-btn" id="tab-btn-1" value="" checked>
  91 + <label for="tab-btn-1">Высшее образование</label>
  92 + <input type="radio" name="tab-btn" id="tab-btn-2" value="">
  93 + <label for="tab-btn-2">Средне-профессиональное образование</label>
  94 + <input type="radio" name="tab-btn" id="tab-btn-3" value="">
  95 + <label for="tab-btn-3">Дополнительное образование</label>
  96 + <div id="content-1">
  97 + <a id="add1" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
  98 + href="{{ route('admin.add-program-education', ['education' => $education->id, 'level' => 1]) }}"
  99 + >Добавить специализацию</a><br>
  100 + @if ((isset($program1)) && ($program1->count()))
  101 + @foreach ($program1 as $prog1)
  102 + <label class="block text-sm">
  103 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">Специальность: {{$prog1->name}}</h4>
  104 + <span class="text-gray-700 dark:text-gray-400">Описание: {{$prog1->text}}</span>
  105 + </label><br><hr>
  106 + @endforeach
  107 + @else
  108 + <span class="text-gray-700 dark:text-gray-400">Нет записей</span>
  109 + @endif
  110 + </div>
  111 + <div id="content-2">
  112 + <a id="add2" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
  113 + href="{{ route('admin.add-program-education', ['education' => $education->id, 'level' => 2]) }}"
  114 + >Добавить специализацию</a><br>
  115 + @if ((isset($program2)) && ($program2->count()))
  116 + @foreach ($program2 as $prog2)
  117 + <label class="block text-sm">
  118 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">Специальность: {{$prog2->name}}</h4>
  119 + <span class="text-gray-700 dark:text-gray-400">Описание: {{$prog2->text}}</span>
  120 + </label><br><hr>
  121 + @endforeach
  122 + @else
  123 + <span class="text-gray-700 dark:text-gray-400">Нет записей</span>
  124 + @endif
  125 + </div>
  126 + <div id="content-3">
  127 + <a id="add3" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
  128 + href="{{ route('admin.add-program-education', ['education' => $education->id, 'level' => 3]) }}"
  129 + >Добавить специализацию</a><br>
  130 + @if ((isset($program3)) && ($program3->count()))
  131 + @foreach ($program3 as $prog3)
  132 + <label class="block text-sm">
  133 + <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">Специальность: {{$prog3->name}}</h4>
  134 + <span class="text-gray-700 dark:text-gray-400">Описание: {{$prog3->text}}</span>
  135 + </label><br><hr>
  136 + @endforeach
  137 + @else
  138 + <span class="text-gray-700 dark:text-gray-400">Нет записей</span>
  139 + @endif
  140 + </div>
  141 + </div><br>
  142 + @endisset
  143 +
87 144 <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
88 145 <div>
89 146 <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
resources/views/admin/education/program.blade.php
... ... @@ -0,0 +1,45 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Образование - добавление программы обучения'])
  2 +
  3 +@section('content')
  4 + <form method="POST" action="{{ route('admin.store-program-education') }}">
  5 + @csrf
  6 +
  7 + <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  8 + <input type="hidden" id="education_id" name="education_id" value="{{ $id_education }}"/>
  9 + <input type="hidden" id="level" name="level" value="{{ $level }}"/>
  10 +
  11 + <label class="block text-sm">
  12 + <span class="text-gray-700 dark:text-gray-400">Название специализации</span>
  13 + <input name="name" id="name"
  14 + class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
  15 + placeholder="Название специализации" required value="{{ old('name') ?? '' }}"
  16 + />
  17 + @error('name')
  18 + <span class="text-xs text-red-600 dark:text-red-400">
  19 + {{ $message }}
  20 + </span>
  21 + @enderror
  22 + </label><br>
  23 +
  24 + <label class="block text-sm">
  25 + <span class="text-gray-700 dark:text-gray-400">Текст</span>
  26 + <textarea class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-textarea focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray ckeditor" name="text" placeholder="Текст (html)" required
  27 + rows="10">{{ old('text') ?? '' }}</textarea>
  28 + @error('text')
  29 + <span class="text-xs text-red-600 dark:text-red-400">
  30 + {{ $message }}
  31 + </span>
  32 + @enderror
  33 + </label><br>
  34 +
  35 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  36 + <div>
  37 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  38 + Сохранить
  39 + </button>
  40 + </div>
  41 + </div>
  42 + </div>
  43 + </form>
  44 +
  45 +@endsection
resources/views/admin/pages/form.blade.php
... ... @@ -75,7 +75,7 @@
75 75  
76 76 <label class="block text-sm">
77 77 <span class="text-gray-700 dark:text-gray-400">Анонс</span>
78   - <textarea class="form-control ckeditor" name="anons" placeholder="Анонс (html)" required
  78 + <textarea class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-textarea focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray ckeditor" name="anons" placeholder="Анонс (html)" required
79 79 rows="10">{{ old('anons') ?? $page->anons ?? '' }}</textarea>
80 80 @error('anons')
81 81 <span class="text-xs text-red-600 dark:text-red-400">
... ... @@ -86,7 +86,7 @@
86 86  
87 87 <label class="block text-sm">
88 88 <span class="text-gray-700 dark:text-gray-400">Текст</span>
89   - <textarea class="form-control ckeditor" name="text" placeholder="Текст (html)" required
  89 + <textarea class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-textarea focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray ckeditor" name="text" placeholder="Текст (html)" required
90 90 rows="10">{{ old('text') ?? $page->text ?? '' }}</textarea>
91 91 @error('text')
92 92 <span class="text-xs text-red-600 dark:text-red-400">
... ... @@ -215,6 +215,9 @@ Route::group([
215 215 // CRUD-операции над справочником Образование
216 216 Route::resource('education', EducationController::class, ['except' => ['show']]);
217 217  
  218 + Route::get('program-education/{education}/{level}', [EducationController::class, 'add_program'])->name('add-program-education');
  219 + Route::post('program-education', [EducationController::class, 'store_program'])->name('store-program-education');
  220 +
218 221 //Route::get('job-titles', [AdminController::class, 'index'])->name('job-titles');
219 222 /*
220 223 * кабинет - CRUD-операции по справочнику должности