Commit dd87a3ce43ad11ea72219a8b2e020a5817572b99
1 parent
e74a6ce9fa
Exists in
master
and in
1 other branch
Реклама-блок, обновление ckeditor обработчика, меню-шапки-футера
Showing 13 changed files with 458 additions and 26 deletions Side-by-side Diff
- app/Http/Controllers/Admin/CompanyController.php
- app/Http/Controllers/CKEditorController.php
- app/Http/Requests/ReclameRequest.php
- app/Models/reclame.php
- public/images/jquery-ui-in-action_1694607980.jpg
- resources/views/admin/editbloks/index.blade.php
- resources/views/admin/editbloks/index_ajax.blade.php
- resources/views/admin/pages/form.blade.php
- resources/views/admin/reclames/add.blade.php
- resources/views/admin/reclames/edit.blade.php
- resources/views/admin/reclames/form.blade.php
- resources/views/admin/reclames/index.blade.php
- routes/web.php
app/Http/Controllers/Admin/CompanyController.php
... | ... | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; |
5 | 5 | use App\Classes\Meta; |
6 | 6 | use App\Http\Controllers\Controller; |
7 | 7 | use App\Http\Requests\PagesRequest; |
8 | +use App\Http\Requests\ReclameRequest; | |
8 | 9 | use App\Http\Requests\SEORequest; |
9 | 10 | use App\Models\Employer; |
10 | 11 | use App\Models\employers_main; |
... | ... | @@ -15,6 +16,7 @@ use App\Models\pages; |
15 | 16 | use App\Models\reclame; |
16 | 17 | use App\Models\SEO; |
17 | 18 | use Illuminate\Http\Request; |
19 | +use Illuminate\Support\Facades\Storage; | |
18 | 20 | |
19 | 21 | class CompanyController extends Controller |
20 | 22 | { |
... | ... | @@ -42,9 +44,16 @@ class CompanyController extends Controller |
42 | 44 | } |
43 | 45 | |
44 | 46 | // кабинет - редактор шапки-футера сайта |
45 | - public function editblocks() { | |
46 | - $header_footer = header_footer::query()->OrderBy('name')->paginate(15); | |
47 | - return view('admin.editbloks.index', compact('header_footer')); | |
47 | + public function editblocks(Request $request) { | |
48 | + if ($request->ajax()) { | |
49 | + $header_footer = header_footer::where('header', $request->header)->OrderBy('sort')->OrderBy('name')->paginate(15); | |
50 | + $list_menu = header_footer::where('header', $request->header)->OrderBy('name')->get(); | |
51 | + return view('admin.editbloks.index_ajax', compact('header_footer')); | |
52 | + } else { | |
53 | + $header_footer = header_footer::where('header', '1')->OrderBy('sort')->OrderBy('name')->paginate(15); | |
54 | + $list_menu = header_footer::where('header', '1')->OrderBy('name')->get(); | |
55 | + return view('admin.editbloks.index', compact('header_footer')); | |
56 | + } | |
48 | 57 | } |
49 | 58 | |
50 | 59 | // кабинет - редактор работодатели на главной |
... | ... | @@ -123,7 +132,12 @@ class CompanyController extends Controller |
123 | 132 | } |
124 | 133 | |
125 | 134 | public function editor_pages_store(PagesRequest $request) { |
126 | - pages::create($request->all()); | |
135 | + $params = $request->all(); | |
136 | + if ($request->has('image')) { | |
137 | + $params['image'] = $request->file('image')->store('pages', 'public'); | |
138 | + } | |
139 | + | |
140 | + pages::create($params); | |
127 | 141 | return redirect()->route('admin.editor-pages'); |
128 | 142 | } |
129 | 143 | |
... | ... | @@ -132,7 +146,16 @@ class CompanyController extends Controller |
132 | 146 | } |
133 | 147 | |
134 | 148 | public function editor_pages_update(PagesRequest $request, pages $page) { |
135 | - $page->update($request->all()); | |
149 | + $params = $request->all(); | |
150 | + | |
151 | + if ($request->has('image')) { | |
152 | + if (!empty($page->image)) Storage::delete($page->image); | |
153 | + $params['image'] = $request->file('image')->store('pages', 'public'); | |
154 | + } else { | |
155 | + if (!empty($page->image)) $params['image'] = $page->image; | |
156 | + } | |
157 | + | |
158 | + $page->update($params); | |
136 | 159 | return redirect()->route('admin.editor-pages'); |
137 | 160 | } |
138 | 161 | |
... | ... | @@ -142,9 +165,58 @@ class CompanyController extends Controller |
142 | 165 | } |
143 | 166 | /////////////////////////////////////////////////////////////////// |
144 | 167 | |
145 | - // кабинет - реклама сайта | |
168 | + ////// кабинет - реклама сайта //////////////////////////////////// | |
146 | 169 | public function reclames() { |
147 | 170 | $reclames = reclame::query()->OrderBy('title')->paginate(15); |
148 | 171 | return view('admin.reclames.index', compact('reclames')); |
149 | 172 | } |
173 | + | |
174 | + public function reclames_add() { | |
175 | + return view('admin.reclames.add'); | |
176 | + } | |
177 | + | |
178 | + public function reclames_store(ReclameRequest $request) { | |
179 | + $params = $request->all(); | |
180 | + /*if('on' == $request->get('is_hidden')) { | |
181 | + $params['is_hidden'] = 1; | |
182 | + } else { | |
183 | + $params['is_hidden'] = 0; | |
184 | + }*/ | |
185 | + if ($request->has('image')) { | |
186 | + $params['image'] = $request->file('image')->store('reclames', 'public'); | |
187 | + } | |
188 | + | |
189 | + reclame::create($params); | |
190 | + return redirect()->route('admin.reclames'); | |
191 | + } | |
192 | + | |
193 | + public function reclames_edit(reclame $reclame) { | |
194 | + return view('admin.reclames.edit', compact('reclame')); | |
195 | + } | |
196 | + | |
197 | + public function reclames_update(ReclameRequest $request, reclame $reclame) { | |
198 | + $params = $request->all(); | |
199 | + /*if('on' == $request->get('is_hidden')) { | |
200 | + $params['is_hidden'] = 1; | |
201 | + } else { | |
202 | + $params['is_hidden'] = 0; | |
203 | + }*/ | |
204 | + | |
205 | + if ($request->has('image')) { | |
206 | + if (!empty($reclame->image)) Storage::delete($reclame->image); | |
207 | + $params['image'] = $request->file('image')->store('reclames', 'public'); | |
208 | + } else { | |
209 | + if (!empty($reclame->image)) $params['image'] = $reclame->image; | |
210 | + } | |
211 | + | |
212 | + $reclame->update($params); | |
213 | + return redirect()->route('admin.reclames'); | |
214 | + } | |
215 | + | |
216 | + public function reclames_destroy(reclame $reclame) { | |
217 | + $reclame->delete(); | |
218 | + return redirect()->route('admin.reclames'); | |
219 | + } | |
220 | + | |
221 | + ///////////////////////////////////////////////////////////////// | |
150 | 222 | } |
app/Http/Controllers/CKEditorController.php
... | ... | @@ -3,19 +3,22 @@ |
3 | 3 | namespace App\Http\Controllers; |
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | +use Illuminate\Support\Facades\Storage; | |
6 | 7 | |
7 | 8 | class CKEditorController extends Controller |
8 | 9 | { |
9 | 10 | public function upload(Request $request) |
10 | 11 | { |
11 | 12 | if($request->hasFile('upload')) { |
12 | - $originName = $request->file('upload')->getClientOriginalName(); | |
13 | + /*$originName = $request->file('upload')->getClientOriginalName(); | |
13 | 14 | $fileName = pathinfo($originName, PATHINFO_FILENAME); |
14 | 15 | $extension = $request->file('upload')->getClientOriginalExtension(); |
15 | 16 | $fileName = $fileName.'_'.time().'.'.$extension; |
16 | 17 | $request->file('upload')->move(public_path('images'), $fileName); |
17 | 18 | $CKEditorFuncNum = $request->input('CKEditorFuncNum'); |
18 | - $url = asset('images/'.$fileName); | |
19 | + $url = asset('images/'.$fileName); */ | |
20 | + $CKEditorFuncNum = $request->input('CKEditorFuncNum'); | |
21 | + $url = asset(Storage::url($request->file('upload')->store('pages', 'public'))); | |
19 | 22 | $msg = 'Image successfully uploaded'; |
20 | 23 | $response = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$msg')</script>"; |
21 | 24 |
app/Http/Requests/ReclameRequest.php
... | ... | @@ -0,0 +1,65 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Requests; | |
4 | + | |
5 | +use Illuminate\Foundation\Http\FormRequest; | |
6 | + | |
7 | +class ReclameRequest 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 | + 'title' => [ | |
28 | + 'required', | |
29 | + 'string', | |
30 | + 'min:3', | |
31 | + 'max:255', | |
32 | + ], | |
33 | + 'image' => [ | |
34 | + 'mimes:jpeg,jpg,png', | |
35 | + 'max:15000', | |
36 | + ], | |
37 | + 'position' => [ | |
38 | + 'required', | |
39 | + 'numeric', | |
40 | + 'min:0', | |
41 | + ], | |
42 | + ]; | |
43 | + } | |
44 | + | |
45 | + public function messages() { | |
46 | + return [ | |
47 | + 'required' => 'Поле :attribute обязательно для ввода', | |
48 | + 'unique' => 'Поле :attribute должно быть уникальным', | |
49 | + 'mimes' => 'Допускаются файлы только с расширением jpeg,jpg,png', | |
50 | + 'numeric' => 'Поле :attribute должно быть числом', | |
51 | + 'min' => [ | |
52 | + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | |
53 | + 'integer' => 'Поле «:attribute» должно быть :min или больше', | |
54 | + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | |
55 | + ], | |
56 | + | |
57 | + 'max' => [ | |
58 | + 'string' => 'Поле «:attribute» должно быть не больше :max символов', | |
59 | + 'integer' => 'Поле «:attribute» должно быть :max или меньше', | |
60 | + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | |
61 | + ], | |
62 | + | |
63 | + ]; | |
64 | + } | |
65 | +} |
app/Models/reclame.php
... | ... | @@ -8,4 +8,15 @@ use Illuminate\Database\Eloquent\Model; |
8 | 8 | class reclame extends Model |
9 | 9 | { |
10 | 10 | use HasFactory; |
11 | + | |
12 | + protected $fillable = [ | |
13 | + 'title', | |
14 | + 'image', | |
15 | + 'link', | |
16 | + 'text', | |
17 | + 'position', | |
18 | + 'is_hidden', | |
19 | + 'col_vo_click', | |
20 | + 'is_remove', | |
21 | + ]; | |
11 | 22 | } |
public/images/jquery-ui-in-action_1694607980.jpg
9.22 KB
resources/views/admin/editbloks/index.blade.php
1 | 1 | @extends('layout.admin', ['title' => 'Админка - Редактор шапки-футера сайта']) |
2 | 2 | |
3 | 3 | @section('script') |
4 | + <script> | |
5 | + $(document).ready(function() { | |
6 | + $(document).on('chance', '#header', function () { | |
7 | + var this_ = $(this); | |
8 | + var value = this_.val(); | |
9 | + var ajax_block = $('#ajax_block'); | |
4 | 10 | |
11 | + $.ajax({ | |
12 | + type: "GET", | |
13 | + url: "{{ url()->full()}}", | |
14 | + data: "header=" + value, | |
15 | + success: function (data) { | |
16 | + console.log('Обновление таблицы меню '); | |
17 | + ajax_block.html(data); | |
18 | + }, | |
19 | + headers: { | |
20 | + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
21 | + }, | |
22 | + error: function (data) { | |
23 | + console.log('Error: ' + data); | |
24 | + } | |
25 | + }); | |
26 | + }); | |
27 | + | |
28 | + }); | |
29 | + </script> | |
5 | 30 | @endsection |
6 | 31 | |
7 | 32 | @section('search') |
... | ... | @@ -38,6 +63,11 @@ |
38 | 63 | <a href="{{ route('admin.add-seo') }}" style="width: 145px" 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"> |
39 | 64 | Добавить опцию |
40 | 65 | </a> |
66 | + <select name="header" id="header" class="form-control"> | |
67 | + <option value="1">Шапка</option> | |
68 | + <option value="0">Футер</option> | |
69 | + </select> | |
70 | + | |
41 | 71 | <br> |
42 | 72 | <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> |
43 | 73 | |
... | ... | @@ -50,8 +80,8 @@ |
50 | 80 | <th class="px-4 py-3">№</th> |
51 | 81 | <th class="px-4 py-3">Название</th> |
52 | 82 | <th class="px-4 py-3">Ссылка</th> |
53 | - <th class="px-4 py-3">Категория</th> | |
54 | - <th class="px-4 py-3">Шапка</th> | |
83 | + <th class="px-4 py-3">Родитель</th> | |
84 | + <th class="px-4 py-3">Сортировка</th> | |
55 | 85 | <th class="px-4 py-3">Дата создания</th> |
56 | 86 | <th class="px-4 py-3">Редактировать</th> |
57 | 87 | </tr> |
... | ... | @@ -69,18 +99,51 @@ |
69 | 99 | {{$page->link}} |
70 | 100 | </td> |
71 | 101 | <td class="px-4 py-3"> |
72 | - {{$page->category}} ({{$page->code_id}}) | |
102 | + <select name="code_id{{$page->code_id}}" id="{{$page->id}}" data-field="code_id" class="form-control check_js"> | |
103 | + <option value="0" | |
104 | + @if($page->code_id == 0) | |
105 | + selected | |
106 | + @endif | |
107 | + >Не указано</option> | |
108 | + @isset($list_menu) | |
109 | + @foreach($list_menu as $menu) | |
110 | + <option value="{{ $menu->id }}" | |
111 | + @if($menu->id == $page->code_id) | |
112 | + selected | |
113 | + @endif | |
114 | + >{{ $menu->name }} ({{ $menu->id }})</option> | |
115 | + @endforeach | |
116 | + @endisset | |
117 | + </select> | |
73 | 118 | </td> |
119 | + <td class="px-4 py-3 text-sm"> | |
120 | + <select name="sort{{$page->id}}" id="{{$page->id}}" data-field="sort" class="form-control check_js"> | |
121 | + <option value="100" @if($page->sort == '100') selected @endif>100</option> | |
122 | + <option value="110" @if($page->sort == '110') selected @endif>110</option> | |
123 | + <option value="120" @if($page->sort == '120') selected @endif>120</option> | |
124 | + <option value="130" @if($page->sort == '130') selected @endif>130</option> | |
125 | + <option value="140" @if($page->sort == '140') selected @endif>140</option> | |
126 | + <option value="150" @if($page->sort == '150') selected @endif>150</option> | |
127 | + <option value="160" @if($page->sort == '160') selected @endif>160</option> | |
128 | + <option value="170" @if($page->sort == '170') selected @endif>170</option> | |
129 | + <option value="180" @if($page->sort == '180') selected @endif>180</option> | |
130 | + <option value="190" @if($page->sort == '190') selected @endif>190</option> | |
131 | + <option value="200" @if($page->sort == '200') selected @endif>200</option> | |
132 | + </select> | |
133 | + </td> | |
134 | + | |
74 | 135 | <td class="px-4 py-3"> |
75 | 136 | {{$page->created_at}} |
76 | 137 | </td> |
77 | 138 | <td class="px-4 py-3 text-sm_"> |
139 | + <? /*?> | |
78 | 140 | <form action="{{ route('admin.delete-seo', ['page' => $page->id]) }}" method="POST"> |
79 | 141 | <a href="{{ route('admin.edit-seo', ['page' => $page->id]) }}">Изменить</a> | |
80 | 142 | @csrf |
81 | 143 | @method('DELETE') |
82 | 144 | <input class="btn btn-danger" type="submit" value="Удалить"/> |
83 | 145 | </form> |
146 | + <? */ ?> | |
84 | 147 | </td> |
85 | 148 | </tr> |
86 | 149 | @endforeach |
resources/views/admin/editbloks/index_ajax.blade.php
... | ... | @@ -0,0 +1,85 @@ |
1 | +<div class="w-full overflow-x-auto"> | |
2 | + <table class="w-full whitespace-no-wrap"> | |
3 | + <thead> | |
4 | + <tr | |
5 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
6 | + > | |
7 | + <th class="px-4 py-3">№</th> | |
8 | + <th class="px-4 py-3">Название</th> | |
9 | + <th class="px-4 py-3">Ссылка</th> | |
10 | + <th class="px-4 py-3">Родитель</th> | |
11 | + <th class="px-4 py-3">Сортировка</th> | |
12 | + <th class="px-4 py-3">Дата создания</th> | |
13 | + <th class="px-4 py-3">Редактировать</th> | |
14 | + </tr> | |
15 | + </thead> | |
16 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
17 | + @foreach($header_footer as $page) | |
18 | + <tr class="text-gray-700 dark:text-gray-400"> | |
19 | + <td class="px-4 py-3"> | |
20 | + {{$page->id}} | |
21 | + </td> | |
22 | + <td class="px-4 py-3"> | |
23 | + {{$page->name}} | |
24 | + </td> | |
25 | + <td class="px-4 py-3"> | |
26 | + {{$page->link}} | |
27 | + </td> | |
28 | + <td class="px-4 py-3"> | |
29 | + <select name="code_id{{$page->code_id}}" id="{{$page->id}}" data-field="code_id" class="form-control check_js"> | |
30 | + <option value="0" | |
31 | + @if($page->code_id == 0) | |
32 | + selected | |
33 | + @endif | |
34 | + >Не указано</option> | |
35 | + @isset($list_menu) | |
36 | + @foreach($list_menu as $menu) | |
37 | + <option value="{{ $menu->id }}" | |
38 | + @if($menu->id == $page->code_id) | |
39 | + selected | |
40 | + @endif | |
41 | + >{{ $menu->name }} ({{ $menu->id }})</option> | |
42 | + @endforeach | |
43 | + @endisset | |
44 | + </select> | |
45 | + </td> | |
46 | + <td class="px-4 py-3 text-sm"> | |
47 | + <select name="sort{{$page->id}}" id="{{$page->id}}" data-field="sort" class="form-control check_js"> | |
48 | + <option value="100" @if($page->sort == '100') selected @endif>100</option> | |
49 | + <option value="110" @if($page->sort == '110') selected @endif>110</option> | |
50 | + <option value="120" @if($page->sort == '120') selected @endif>120</option> | |
51 | + <option value="130" @if($page->sort == '130') selected @endif>130</option> | |
52 | + <option value="140" @if($page->sort == '140') selected @endif>140</option> | |
53 | + <option value="150" @if($page->sort == '150') selected @endif>150</option> | |
54 | + <option value="160" @if($page->sort == '160') selected @endif>160</option> | |
55 | + <option value="170" @if($page->sort == '170') selected @endif>170</option> | |
56 | + <option value="180" @if($page->sort == '180') selected @endif>180</option> | |
57 | + <option value="190" @if($page->sort == '190') selected @endif>190</option> | |
58 | + <option value="200" @if($page->sort == '200') selected @endif>200</option> | |
59 | + </select> | |
60 | + </td> | |
61 | + | |
62 | + <td class="px-4 py-3"> | |
63 | + {{$page->created_at}} | |
64 | + </td> | |
65 | + <td class="px-4 py-3 text-sm_"> | |
66 | + <? /*?> | |
67 | + <form action="{{ route('admin.delete-seo', ['page' => $page->id]) }}" method="POST"> | |
68 | + <a href="{{ route('admin.edit-seo', ['page' => $page->id]) }}">Изменить</a> | | |
69 | + @csrf | |
70 | + @method('DELETE') | |
71 | + <input class="btn btn-danger" type="submit" value="Удалить"/> | |
72 | + </form> | |
73 | + <? */ ?> | |
74 | + </td> | |
75 | + </tr> | |
76 | + @endforeach | |
77 | + </tbody> | |
78 | + </table> | |
79 | +</div> | |
80 | + | |
81 | +<div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | |
82 | + <?=$header_footer->appends($_GET)->links('admin.pagginate'); ?> | |
83 | +</div> | |
84 | + | |
85 | + |
resources/views/admin/pages/form.blade.php
... | ... | @@ -4,14 +4,6 @@ |
4 | 4 | @method('PUT') |
5 | 5 | @endisset |
6 | 6 | |
7 | -<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> | |
8 | -<script> | |
9 | - CKEDITOR.replace( 'anons'); | |
10 | - CKEDITOR.replace( 'text', { | |
11 | - filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | |
12 | - filebrowserUploadMethod: 'form' | |
13 | - }); | |
14 | -</script> | |
15 | 7 | <script> |
16 | 8 | function translit(word){ |
17 | 9 | var answer = ''; |
... | ... | @@ -55,8 +47,6 @@ |
55 | 47 | |
56 | 48 | </script> |
57 | 49 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> |
58 | - | |
59 | -<label class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> | |
60 | 50 | <label class="block text-sm"> |
61 | 51 | <span class="text-gray-700 dark:text-gray-400">Название страницы</span> |
62 | 52 | <input name="name" id="name" |
... | ... | @@ -120,7 +110,18 @@ |
120 | 110 | |
121 | 111 | <label class="block text-sm"> |
122 | 112 | <span class="text-gray-700 dark:text-gray-400">Картинка</span> |
123 | - <input type="file" 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" id="image" name="image" accept="image/png, image/jpeg"> | |
113 | + <input type="file" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 | |
114 | + focus:border-purple-400 focus:outline-none focus:shadow-outline-purple | |
115 | + dark:text-gray-300 dark:focus:shadow-outline-gray form-input" | |
116 | + id="image" name="image" accept="image/png, image/jpeg"> | |
117 | + @error('image') | |
118 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
119 | + {{ $message }} | |
120 | + </span> | |
121 | + @enderror | |
122 | + @isset($page->image) | |
123 | + <img src="{{asset(Storage::url($page->image))}}" width="100px"/> | |
124 | + @endisset | |
124 | 125 | </label><br> |
125 | 126 | |
126 | 127 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> |
... | ... | @@ -131,3 +132,12 @@ |
131 | 132 | </div> |
132 | 133 | </div> |
133 | 134 | </div> |
135 | +<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> | |
136 | +<script> | |
137 | + CKEDITOR.replace( 'anons'); | |
138 | + CKEDITOR.replace( 'text', { | |
139 | + filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | |
140 | + filebrowserImageUploadUrl: "{{ route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | |
141 | + filebrowserUploadMethod: 'form' | |
142 | + }); | |
143 | +</script> |
resources/views/admin/reclames/add.blade.php
resources/views/admin/reclames/edit.blade.php
... | ... | @@ -0,0 +1,7 @@ |
1 | +@extends('layout.admin', ['title' => 'Админка - Редактирование рекламы']) | |
2 | + | |
3 | +@section('content') | |
4 | + <form method="POST" action="{{ route('admin.update-reclames', ['reclame' => $reclame->id]) }}" enctype="multipart/form-data"> | |
5 | + @include('admin.reclames.form') | |
6 | + </form> | |
7 | +@endsection |
resources/views/admin/reclames/form.blade.php
... | ... | @@ -0,0 +1,98 @@ |
1 | +@csrf | |
2 | + | |
3 | +@isset($reclame) | |
4 | + @method('PUT') | |
5 | +@endisset | |
6 | + | |
7 | +<script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> | |
8 | +<script> | |
9 | + CKEDITOR.replace( 'text', { | |
10 | + filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | |
11 | + filebrowserUploadMethod: 'form' | |
12 | + }); | |
13 | +</script> | |
14 | +<div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> | |
15 | + <label class="block text-sm"> | |
16 | + <span class="text-gray-700 dark:text-gray-400">Заголовок рекламы</span> | |
17 | + <input name="title" id="title" | |
18 | + 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" | |
19 | + placeholder="Заголовок рекламы" value="{{ old('title') ?? $reclame->title ?? '' }}" | |
20 | + /> | |
21 | + @error('title') | |
22 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
23 | + {{ $message }} | |
24 | + </span> | |
25 | + @enderror | |
26 | + </label><br> | |
27 | + | |
28 | + <label class="block text-sm"> | |
29 | + <span class="text-gray-700 dark:text-gray-400"> | |
30 | + <input type="hidden" name="is_hidden" value="0" /> | |
31 | + <input type="checkbox" value="1" name="is_hidden" id="is_hidden" {{ ($reclame->is_hidden) ? "checked" : "" }} /> | |
32 | + Скрыть рекламу</span> | |
33 | + </label><br> | |
34 | + | |
35 | + <label class="block text-sm"> | |
36 | + <span class="text-gray-700 dark:text-gray-400">Ссылка</span> | |
37 | + <input name="link" id="link" | |
38 | + 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" | |
39 | + placeholder="Ссылка" value="{{ old('link') ?? $reclame->link ?? '' }}" | |
40 | + /> | |
41 | + @error('link') | |
42 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
43 | + {{ $message }} | |
44 | + </span> | |
45 | + @enderror | |
46 | + </label><br> | |
47 | + | |
48 | + <label class="block text-sm"> | |
49 | + <span class="text-gray-700 dark:text-gray-400">Текст</span> | |
50 | + <textarea class="form-control ckeditor" name="text" id="text" placeholder="Текст (html)" required | |
51 | + rows="10">{{ old('text') ?? $reclame->text ?? '' }}</textarea> | |
52 | + @error('text') | |
53 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
54 | + {{ $message }} | |
55 | + </span> | |
56 | + @enderror | |
57 | + </label><br> | |
58 | + | |
59 | + <label class="block text-sm"> | |
60 | + <span class="text-gray-700 dark:text-gray-400">Позиция (число)</span> | |
61 | + <input name="position" id="position" | |
62 | + 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" | |
63 | + placeholder="Позиция" value="{{ old('position') ?? $reclame->position ?? '' }}" | |
64 | + /> | |
65 | + @error('position') | |
66 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
67 | + {{ $message }} | |
68 | + </span> | |
69 | + @enderror | |
70 | + </label><br> | |
71 | + | |
72 | + <label class="block text-sm"> | |
73 | + <span class="text-gray-700 dark:text-gray-400">Картинка</span> | |
74 | + <input type="file" class="block w-full mt-1 text-sm dark:border-gray-600 | |
75 | + dark:bg-gray-700 focus:border-purple-400 | |
76 | + focus:outline-none focus:shadow-outline-purple | |
77 | + dark:text-gray-300 dark:focus:shadow-outline-gray | |
78 | + form-input" | |
79 | + id="image" name="image" accept="image/png, image/jpeg"> | |
80 | + @error('image') | |
81 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
82 | + {{ $message }} | |
83 | + </span> | |
84 | + @enderror | |
85 | + @isset($reclame->image) | |
86 | + <img src="{{asset(Storage::url($reclame->image))}}" width="100px"/> | |
87 | + @endisset | |
88 | + | |
89 | + </label><br> | |
90 | + | |
91 | + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> | |
92 | + <div> | |
93 | + <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"> | |
94 | + Сохранить | |
95 | + </button> | |
96 | + </div> | |
97 | + </div> | |
98 | +</div> |
resources/views/admin/reclames/index.blade.php
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | |
36 | 36 | @section('content') |
37 | 37 | |
38 | - <a href="{{ route('admin.add-seo') }}" style="width: 160px" 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 | + <a href="{{ route('admin.add-reclames') }}" style="width: 160px" 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"> | |
39 | 39 | Добавить рекламу |
40 | 40 | </a> |
41 | 41 | <br> |
... | ... | @@ -72,14 +72,18 @@ |
72 | 72 | {{$reclame->position}} |
73 | 73 | </td> |
74 | 74 | <td class="px-4 py-3"> |
75 | - {{$reclame->is_hidden}} | |
75 | + @if ($reclame->is_hidden) | |
76 | + Скрыто | |
77 | + @else | |
78 | + Показано | |
79 | + @endif | |
76 | 80 | </td> |
77 | 81 | <td class="px-4 py-3"> |
78 | 82 | {{$reclame->col_vo_click}} |
79 | 83 | </td> |
80 | 84 | <td class="px-4 py-3 text-sm_"> |
81 | - <form action="{{ route('admin.delete-seo', ['page' => $reclame->id]) }}" method="POST"> | |
82 | - <a href="{{ route('admin.edit-seo', ['page' => $reclame->id]) }}">Изменить</a> | | |
85 | + <form action="{{ route('admin.delete-reclames', ['reclame' => $reclame->id]) }}" method="POST"> | |
86 | + <a href="{{ route('admin.edit-reclames', ['reclame' => $reclame->id]) }}">Изменить</a> | | |
83 | 87 | @csrf |
84 | 88 | @method('DELETE') |
85 | 89 | <input class="btn btn-danger" type="submit" value="Удалить"/> |
routes/web.php
... | ... | @@ -180,6 +180,7 @@ Route::group([ |
180 | 180 | // кабинет - редактор работодатели на главной |
181 | 181 | Route::get('employers-main', [CompanyController::class, 'employers_main'])->name('employers-main'); |
182 | 182 | |
183 | + | |
183 | 184 | // кабинет - редактор seo-сайта |
184 | 185 | Route::get('editor-seo', [CompanyController::class, 'editor_seo'])->name('editor-seo'); |
185 | 186 | Route::get('editor-seo/add', [CompanyController::class, 'editor_seo_add'])->name('add-seo'); |
... | ... | @@ -206,8 +207,14 @@ Route::group([ |
206 | 207 | |
207 | 208 | // кабинет - реклама сайта |
208 | 209 | Route::get('reclames', [CompanyController::class, 'reclames'])->name('reclames'); |
210 | + Route::get('reclames/add', [CompanyController::class, 'reclames_add'])->name('add-reclames'); | |
211 | + Route::post('reclames/add', [CompanyController::class, 'reclames_store'])->name('add-reclames-store'); | |
212 | + Route::get('reclames/edit/{reclame}', [CompanyController::class, 'reclames_edit'])->name('edit-reclames'); | |
213 | + Route::put('reclames/edit/{reclame}', [CompanyController::class, 'reclames_update'])->name('update-reclames'); | |
214 | + Route::delete('reclames/delete/{reclame}', [CompanyController::class, 'reclames_destroy'])->name('delete-reclames'); | |
209 | 215 | //////////////////////////////////////////////////////////////////////// |
210 | 216 | |
217 | + | |
211 | 218 | // кабинет - отзывы о работодателе для модерации |
212 | 219 | Route::get('answers', [EmployersController::class, 'answers'])->name('answers'); |
213 | 220 |