Commit 46be695f582eddf57b3be55715f7272835f1d84b

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

Образование и специализации в учебных заведениях

Showing 6 changed files with 119 additions and 11 deletions Side-by-side Diff

app/Http/Controllers/Admin/EducationController.php
... ... @@ -70,17 +70,8 @@ class EducationController extends Controller
70 70 */
71 71 public function edit(Education $education)
72 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();
79   - */
80   -
81 73 $program = ProgramEducation::query()->where('education_id', '=', $education->id)
82 74 ->orderBy('level')->get();
83   -
84 75 return view('admin.education.edit', compact('education', 'program'));
85 76 }
86 77  
... ... @@ -130,4 +121,11 @@ class EducationController extends Controller
130 121 return redirect()->route('admin.education.edit', ['education' => $education]);
131 122 }
132 123  
  124 + public function delete_program(ProgramEducation $program, Education $education) {
  125 + $education = $education->id;
  126 + $program->delete();
  127 +
  128 + return redirect()->route('admin.education.edit', ['education' => $education]);
  129 + }
  130 +
133 131 }
resources/views/admin/education/add.blade.php
... ... @@ -2,6 +2,6 @@
2 2  
3 3 @section('content')
4 4 <form method="POST" action="{{ route('admin.education.store') }}" enctype="multipart/form-data">
5   - @include('admin.education.form')
  5 + @include('admin.education.form-add')
6 6 </form>
7 7 @endsection
resources/views/admin/education/form-add.blade.php
... ... @@ -0,0 +1,108 @@
  1 +@csrf
  2 +
  3 +@isset($education)
  4 + @method('PUT')
  5 +@endisset
  6 +
  7 +<div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  8 + <label class="block text-sm">
  9 + <span class="text-gray-700 dark:text-gray-400">Название учебного заведения</span>
  10 + <input name="name" id="name"
  11 + 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"
  12 + placeholder="Название учебного заведения" value="{{ old('name') ?? $education->name ?? '' }}"
  13 + />
  14 + @error('name')
  15 + <span class="text-xs text-red-600 dark:text-red-400">
  16 + {{ $message }}
  17 + </span>
  18 + @enderror
  19 + </label><br>
  20 +
  21 + <label class="block text-sm">
  22 + <span class="text-gray-700 dark:text-gray-400">Адрес</span>
  23 + <input name="address" id="address"
  24 + 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"
  25 + placeholder="Адрес" value="{{ old('address') ?? $education->address ?? '' }}"
  26 + />
  27 + @error('address')
  28 + <span class="text-xs text-red-600 dark:text-red-400">
  29 + {{ $message }}
  30 + </span>
  31 + @enderror
  32 + </label><br>
  33 +
  34 + <label class="block text-sm">
  35 + <span class="text-gray-700 dark:text-gray-400">Email</span>
  36 + <input name="email" id="email"
  37 + 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"
  38 + placeholder="Email" value="{{ old('email') ?? $education->email ?? '' }}"
  39 + />
  40 + @error('email')
  41 + <span class="text-xs text-red-600 dark:text-red-400">
  42 + {{ $message }}
  43 + </span>
  44 + @enderror
  45 + </label><br>
  46 +
  47 + <label class="block text-sm">
  48 + <span class="text-gray-700 dark:text-gray-400">Телефон</span>
  49 + <input name="telephone" id="telephone"
  50 + 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"
  51 + placeholder="Телефон" value="{{ old('telephone') ?? $education->telephone ?? '' }}"
  52 + />
  53 + @error('telephone')
  54 + <span class="text-xs text-red-600 dark:text-red-400">
  55 + {{ $message }}
  56 + </span>
  57 + @enderror
  58 + </label><br>
  59 +
  60 + <label class="block text-sm">
  61 + <span class="text-gray-700 dark:text-gray-400">Текст</span>
  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 + rows="10">{{ old('text') ?? $education->text ?? '' }}</textarea>
  64 + @error('text')
  65 + <span class="text-xs text-red-600 dark:text-red-400">
  66 + {{ $message }}
  67 + </span>
  68 + @enderror
  69 + </label><br>
  70 +
  71 + <label class="block text-sm">
  72 + <span class="text-gray-700 dark:text-gray-400">Картинка</span>
  73 + <input type="file" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700
  74 + focus:border-purple-400 focus:outline-none focus:shadow-outline-purple
  75 + dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
  76 + id="image" name="image" accept="image/png, image/jpeg">
  77 + @error('image')
  78 + <span class="text-xs text-red-600 dark:text-red-400">
  79 + {{ $message }}
  80 + </span>
  81 + @enderror
  82 + @isset($education->image)
  83 + <img src="{{asset(Storage::url($education->image))}}" width="100px"/>
  84 + @endisset
  85 + </label><br>
  86 +
  87 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  88 + <div>
  89 + <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">
  90 + Сохранить
  91 + </button>
  92 + <a href="{{ route('admin.education.index') }}"
  93 + 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"
  94 + style="display: -webkit-inline-box; height: 30px!important;"
  95 + >Назад</a>
  96 + </div>
  97 + </div>
  98 +</div>
  99 +<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script>
  100 +
  101 +<!--<script src="{{ asset('./ckeditor/ckeditor.js') }}"></script>-->
  102 +<script>
  103 + CKEDITOR.replace( 'text', {
  104 + filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}",
  105 + filebrowserImageUploadUrl: "{{ route('ckeditor.image-upload', ['_token' => csrf_token() ])}}",
  106 + filebrowserUploadMethod: 'form'
  107 + });
  108 +</script>
resources/views/admin/education/form.blade.php
... ... @@ -139,6 +139,7 @@
139 139 <label class="block text-sm">
140 140 <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300">Специальность: {{$pro->name}}</h4>
141 141 <span class="text-gray-700 dark:text-gray-400">Описание: {{$pro->text}}</span>
  142 + <a href="{{ route('admin.delete-program-education', ['program' => $pro->id, 'education' => $education->id]) }}">Удалить</a>
142 143 </label><br><hr>
143 144 @endforeach
144 145 </div>
resources/views/admin/education/index.blade.php
... ... @@ -35,7 +35,7 @@
35 35 {{$cat->id}}
36 36 </td>
37 37 <td class="px-4 py-3">
38   - {{ $cat->name }}
  38 + {{ mb_strimwidth($cat->name, 0, 50, "...") }}
39 39 </td>
40 40  
41 41 <td class="px-4 py-3 text-sm_">
... ... @@ -228,6 +228,7 @@ Route::group([
228 228  
229 229 Route::get('program-education', [EducationController::class, 'add_program'])->name('add-program-education');
230 230 Route::post('program-education', [EducationController::class, 'store_program'])->name('store-program-education');
  231 + Route::get('program-education/delete/{program}/{education}', [EducationController::class, 'delete_program'])->name('delete-program-education');
231 232  
232 233 //Route::get('job-titles', [AdminController::class, 'index'])->name('job-titles');
233 234 /*