Commit 9779d2e57803414392c0b3c52470688940b3fe59
1 parent
5558bda14b
Exists in
master
allow set counters description empty
Showing 2 changed files with 4 additions and 2 deletions Inline Diff
app/Http/Controllers/Admin/CompanyController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers\Admin; | 3 | namespace App\Http\Controllers\Admin; |
4 | 4 | ||
5 | use App\Classes\Meta; | 5 | use App\Classes\Meta; |
6 | use App\Http\Controllers\Controller; | 6 | use App\Http\Controllers\Controller; |
7 | use App\Http\Requests\PagesRequest; | 7 | use App\Http\Requests\PagesRequest; |
8 | use App\Http\Requests\ReclameRequest; | 8 | use App\Http\Requests\ReclameRequest; |
9 | use App\Http\Requests\SEORequest; | 9 | use App\Http\Requests\SEORequest; |
10 | use App\Models\Employer; | 10 | use App\Models\Employer; |
11 | use App\Models\employers_main; | 11 | use App\Models\employers_main; |
12 | use App\Models\header_footer; | 12 | use App\Models\header_footer; |
13 | use App\Models\Job_title; | 13 | use App\Models\Job_title; |
14 | use App\Models\job_titles_main; | 14 | use App\Models\job_titles_main; |
15 | use App\Models\pages; | 15 | use App\Models\pages; |
16 | use App\Models\reclame; | 16 | use App\Models\reclame; |
17 | use App\Models\SEO; | 17 | use App\Models\SEO; |
18 | use App\Models\PageContent; | 18 | use App\Models\PageContent; |
19 | use Illuminate\Http\Request; | 19 | use Illuminate\Http\Request; |
20 | use Illuminate\Support\Facades\Storage; | 20 | use Illuminate\Support\Facades\Storage; |
21 | use App\Enums\MainPageCounters; | 21 | use App\Enums\MainPageCounters; |
22 | 22 | ||
23 | class CompanyController extends Controller | 23 | class CompanyController extends Controller |
24 | { | 24 | { |
25 | // кабинет - редактор сайта | 25 | // кабинет - редактор сайта |
26 | public function editor() { | 26 | public function editor() { |
27 | return; | 27 | return; |
28 | } | 28 | } |
29 | 29 | ||
30 | // кабинет - редактор должности на главной | 30 | // кабинет - редактор должности на главной |
31 | public function job_titles_main(Request $request) { | 31 | public function job_titles_main(Request $request) { |
32 | if ($request->ajax()) { | 32 | if ($request->ajax()) { |
33 | $user = job_titles_main::find($request->id); | 33 | $user = job_titles_main::find($request->id); |
34 | $request->offsetUnset('id'); | 34 | $request->offsetUnset('id'); |
35 | $user->update($request->all()); | 35 | $user->update($request->all()); |
36 | } | 36 | } |
37 | 37 | ||
38 | $jobs = job_titles_main::query()->OrderBy('sort')->paginate(10); | 38 | $jobs = job_titles_main::query()->OrderBy('sort')->paginate(10); |
39 | $list_job_titles = Job_title::query()->active()->orderBy('name')->get(); | 39 | $list_job_titles = Job_title::query()->active()->orderBy('name')->get(); |
40 | 40 | ||
41 | if ($request->ajax()) { | 41 | if ($request->ajax()) { |
42 | return view('admin.job_main.index_ajax', compact('jobs', 'list_job_titles')); | 42 | return view('admin.job_main.index_ajax', compact('jobs', 'list_job_titles')); |
43 | } else { | 43 | } else { |
44 | return view('admin.job_main.index', compact('jobs', 'list_job_titles')); | 44 | return view('admin.job_main.index', compact('jobs', 'list_job_titles')); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | // кабинет - блок со счетчиками на главной | 48 | // кабинет - блок со счетчиками на главной |
49 | public function counters_main(Request $request) { | 49 | public function counters_main(Request $request) { |
50 | $block_names = MainPageCounters::values(); | 50 | $block_names = MainPageCounters::values(); |
51 | $blocks = PageContent::select('name', 'title', 'description', 'extra') | 51 | $blocks = PageContent::select('name', 'title', 'description', 'extra') |
52 | ->whereIn('name', $block_names) | 52 | ->whereIn('name', $block_names) |
53 | ->get() | 53 | ->get() |
54 | ->keyBy('name') | 54 | ->keyBy('name') |
55 | ->toArray(); | 55 | ->toArray(); |
56 | return view('admin.counters_main.index', compact('block_names', 'blocks')); | 56 | return view('admin.counters_main.index', compact('block_names', 'blocks')); |
57 | } | 57 | } |
58 | 58 | ||
59 | public function counters_main_update(Request $request, string $name) { | 59 | public function counters_main_update(Request $request, string $name) { |
60 | $data = $request->all(); | ||
61 | $data['description'] = $data['description'] ?? ''; | ||
60 | PageContent::updateOrCreate( | 62 | PageContent::updateOrCreate( |
61 | ['name' => $name], | 63 | ['name' => $name], |
62 | array_merge(['name' => $name], $request->all()) | 64 | array_merge(['name' => $name], $data) |
63 | ); | 65 | ); |
64 | $block_names = MainPageCounters::values();; | 66 | $block_names = MainPageCounters::values();; |
65 | $blocks = PageContent::select('name', 'title', 'description', 'extra') | 67 | $blocks = PageContent::select('name', 'title', 'description', 'extra') |
66 | ->whereIn('name', $block_names) | 68 | ->whereIn('name', $block_names) |
67 | ->get() | 69 | ->get() |
68 | ->keyBy('name') | 70 | ->keyBy('name') |
69 | ->toArray(); | 71 | ->toArray(); |
70 | return view('admin.counters_main.index', compact('block_names', 'blocks')); | 72 | return view('admin.counters_main.index', compact('block_names', 'blocks')); |
71 | } | 73 | } |
72 | 74 | ||
73 | //////////////////////////////////////////////////////////////////////////////// | 75 | //////////////////////////////////////////////////////////////////////////////// |
74 | // кабинет - редактор шапки-футера сайта | 76 | // кабинет - редактор шапки-футера сайта |
75 | public function editblocks(Request $request) { | 77 | public function editblocks(Request $request) { |
76 | if ($request->ajax()) { | 78 | if ($request->ajax()) { |
77 | $header_footer = header_footer::where('header', $request->header)->OrderBy('sort')->OrderBy('name')->paginate(15); | 79 | $header_footer = header_footer::where('header', $request->header)->OrderBy('sort')->OrderBy('name')->paginate(15); |
78 | $list_menu = header_footer::where('header', $request->header)->OrderBy('name')->get(); | 80 | $list_menu = header_footer::where('header', $request->header)->OrderBy('name')->get(); |
79 | return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); | 81 | return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); |
80 | } else { | 82 | } else { |
81 | $header_footer = header_footer::where('header', '1')->OrderBy('sort')->OrderBy('name')->paginate(15); | 83 | $header_footer = header_footer::where('header', '1')->OrderBy('sort')->OrderBy('name')->paginate(15); |
82 | $list_menu = header_footer::where('header', '1')->OrderBy('name')->get(); | 84 | $list_menu = header_footer::where('header', '1')->OrderBy('name')->get(); |
83 | return view('admin.editbloks.index', compact('header_footer', 'list_menu')); | 85 | return view('admin.editbloks.index', compact('header_footer', 'list_menu')); |
84 | } | 86 | } |
85 | } | 87 | } |
86 | 88 | ||
87 | public function editblock_add() { | 89 | public function editblock_add() { |
88 | $items = header_footer::query()->OrderBy('name')->get(); | 90 | $items = header_footer::query()->OrderBy('name')->get(); |
89 | return view('admin.editbloks.add', compact('items')); | 91 | return view('admin.editbloks.add', compact('items')); |
90 | } | 92 | } |
91 | 93 | ||
92 | public function editblock_store(Request $request) { | 94 | public function editblock_store(Request $request) { |
93 | header_footer::create($request->all()); | 95 | header_footer::create($request->all()); |
94 | return redirect()->route('admin.edit-blocks'); | 96 | return redirect()->route('admin.edit-blocks'); |
95 | } | 97 | } |
96 | 98 | ||
97 | public function editblock_ajax(Request $request) { | 99 | public function editblock_ajax(Request $request) { |
98 | if ($request->ajax()) { | 100 | if ($request->ajax()) { |
99 | $hf = header_footer::find($request->id); | 101 | $hf = header_footer::find($request->id); |
100 | $filter = $request->header; | 102 | $filter = $request->header; |
101 | unset($request->id); | 103 | unset($request->id); |
102 | unset($request->header); | 104 | unset($request->header); |
103 | $hf->update($request->all()); | 105 | $hf->update($request->all()); |
104 | 106 | ||
105 | $header_footer = header_footer::where('header', $filter)->OrderBy('sort')->OrderBy('name')->paginate(15); | 107 | $header_footer = header_footer::where('header', $filter)->OrderBy('sort')->OrderBy('name')->paginate(15); |
106 | $list_menu = header_footer::where('header', $filter)->OrderBy('name')->get(); | 108 | $list_menu = header_footer::where('header', $filter)->OrderBy('name')->get(); |
107 | return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); | 109 | return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); |
108 | } else { | 110 | } else { |
109 | return "Ошибка!"; | 111 | return "Ошибка!"; |
110 | } | 112 | } |
111 | } | 113 | } |
112 | 114 | ||
113 | public function editblock_edit(header_footer $block) { | 115 | public function editblock_edit(header_footer $block) { |
114 | $items = header_footer::query()->OrderBy('name')->get(); | 116 | $items = header_footer::query()->OrderBy('name')->get(); |
115 | return view('admin.editbloks.edit', compact('block', 'items')); | 117 | return view('admin.editbloks.edit', compact('block', 'items')); |
116 | } | 118 | } |
117 | 119 | ||
118 | public function editblock_update(Request $request, header_footer $block) { | 120 | public function editblock_update(Request $request, header_footer $block) { |
119 | $block->update($request->all()); | 121 | $block->update($request->all()); |
120 | return redirect()->route('admin.edit-blocks'); | 122 | return redirect()->route('admin.edit-blocks'); |
121 | } | 123 | } |
122 | 124 | ||
123 | public function editblock_destroy(header_footer $block) { | 125 | public function editblock_destroy(header_footer $block) { |
124 | $block->delete(); | 126 | $block->delete(); |
125 | return redirect()->route('admin.edit-blocks'); | 127 | return redirect()->route('admin.edit-blocks'); |
126 | } | 128 | } |
127 | ///////////////////////////////////////////////////////// | 129 | ///////////////////////////////////////////////////////// |
128 | 130 | ||
129 | // кабинет - редактор работодатели на главной | 131 | // кабинет - редактор работодатели на главной |
130 | public function employers_main(Request $request) { | 132 | public function employers_main(Request $request) { |
131 | if ($request->ajax()) { | 133 | if ($request->ajax()) { |
132 | $user = employers_main::find($request->id); | 134 | $user = employers_main::find($request->id); |
133 | $request->offsetUnset('id'); | 135 | $request->offsetUnset('id'); |
134 | $user->update($request->all()); | 136 | $user->update($request->all()); |
135 | } | 137 | } |
136 | 138 | ||
137 | $employers = employers_main::query()->OrderBy('sort')->paginate(10); | 139 | $employers = employers_main::query()->OrderBy('sort')->paginate(10); |
138 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); | 140 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); |
139 | 141 | ||
140 | if ($request->ajax()) { | 142 | if ($request->ajax()) { |
141 | return view('admin.employer_main.table', compact('employers', 'list_employers')); | 143 | return view('admin.employer_main.table', compact('employers', 'list_employers')); |
142 | } else { | 144 | } else { |
143 | return view('admin.employer_main.index', compact('employers', 'list_employers')); | 145 | return view('admin.employer_main.index', compact('employers', 'list_employers')); |
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
147 | public function employers_main_add(Request $request) | 149 | public function employers_main_add(Request $request) |
148 | { | 150 | { |
149 | $page = $request->get('page', 1); | 151 | $page = $request->get('page', 1); |
150 | $page = intval($page); | 152 | $page = intval($page); |
151 | 153 | ||
152 | employers_main::insert([ | 154 | employers_main::insert([ |
153 | 'employer_id' => 0, | 155 | 'employer_id' => 0, |
154 | 'sort' => 100 | 156 | 'sort' => 100 |
155 | ]); | 157 | ]); |
156 | 158 | ||
157 | $pageSize = 10; | 159 | $pageSize = 10; |
158 | $offset = ($page - 1) * $pageSize; | 160 | $offset = ($page - 1) * $pageSize; |
159 | $employers = employers_main::query()->OrderBy('sort')->offset($offset)->limit($pageSize)->get(); | 161 | $employers = employers_main::query()->OrderBy('sort')->offset($offset)->limit($pageSize)->get(); |
160 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); | 162 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); |
161 | return view('admin.employer_main.table', compact('employers', 'list_employers')); | 163 | return view('admin.employer_main.table', compact('employers', 'list_employers')); |
162 | } | 164 | } |
163 | 165 | ||
164 | public function employers_main_remove(Request $request) | 166 | public function employers_main_remove(Request $request) |
165 | { | 167 | { |
166 | $id = $request->get('id', 0); | 168 | $id = $request->get('id', 0); |
167 | $page = $request->get('page', 1); | 169 | $page = $request->get('page', 1); |
168 | $page = intval($page); | 170 | $page = intval($page); |
169 | 171 | ||
170 | if ($id !== 0) { | 172 | if ($id !== 0) { |
171 | employers_main::where('id', $id)->delete(); | 173 | employers_main::where('id', $id)->delete(); |
172 | } | 174 | } |
173 | 175 | ||
174 | $pageSize = 10; | 176 | $pageSize = 10; |
175 | $offset = ($page - 1) * $pageSize; | 177 | $offset = ($page - 1) * $pageSize; |
176 | $employers = employers_main::query()->OrderBy('sort')->offset($offset)->limit($pageSize)->get(); | 178 | $employers = employers_main::query()->OrderBy('sort')->offset($offset)->limit($pageSize)->get(); |
177 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); | 179 | $list_employers = Employer::query()->active()->orderBy('name_company')->get(); |
178 | return view('admin.employer_main.table', compact('employers', 'list_employers')); | 180 | return view('admin.employer_main.table', compact('employers', 'list_employers')); |
179 | } | 181 | } |
180 | 182 | ||
181 | //////////// кабинет - редактор seo-сайта ///////////////////////////// | 183 | //////////// кабинет - редактор seo-сайта ///////////////////////////// |
182 | public function editor_seo() { | 184 | public function editor_seo() { |
183 | $pages = SEO::query()->OrderBy('url')->paginate(15); | 185 | $pages = SEO::query()->OrderBy('url')->paginate(15); |
184 | return view('admin.seo.index', compact('pages')); | 186 | return view('admin.seo.index', compact('pages')); |
185 | } | 187 | } |
186 | 188 | ||
187 | public function editor_seo_add() { | 189 | public function editor_seo_add() { |
188 | return view('admin.seo.add'); | 190 | return view('admin.seo.add'); |
189 | } | 191 | } |
190 | 192 | ||
191 | public function editor_seo_store(SEORequest $request) { | 193 | public function editor_seo_store(SEORequest $request) { |
192 | SEO::create($request->all()); | 194 | SEO::create($request->all()); |
193 | return redirect()->route('admin.editor-seo'); | 195 | return redirect()->route('admin.editor-seo'); |
194 | } | 196 | } |
195 | 197 | ||
196 | public function editor_seo_ajax(Request $request) { | 198 | public function editor_seo_ajax(Request $request) { |
197 | $url = $request->get('url'); // post('url'); | 199 | $url = $request->get('url'); // post('url'); |
198 | $metaData = Array(); | 200 | $metaData = Array(); |
199 | //$url = json_decode($url, true); | 201 | //$url = json_decode($url, true); |
200 | 202 | ||
201 | if (!empty($url)) { | 203 | if (!empty($url)) { |
202 | 204 | ||
203 | $meta = new Meta($url); | 205 | $meta = new Meta($url); |
204 | $meta->parse(); | 206 | $meta->parse(); |
205 | $metaData = $meta->finalize(); | 207 | $metaData = $meta->finalize(); |
206 | 208 | ||
207 | return json_encode($metaData); | 209 | return json_encode($metaData); |
208 | } else { | 210 | } else { |
209 | return json_encode(Array('Error URL')); | 211 | return json_encode(Array('Error URL')); |
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | public function editor_seo_edit(SEO $page) { | 215 | public function editor_seo_edit(SEO $page) { |
214 | return view('admin.seo.edit', compact('page')); | 216 | return view('admin.seo.edit', compact('page')); |
215 | } | 217 | } |
216 | 218 | ||
217 | public function editor_seo_update(SEORequest $request, SEO $page) { | 219 | public function editor_seo_update(SEORequest $request, SEO $page) { |
218 | $page->update($request->all()); | 220 | $page->update($request->all()); |
219 | return redirect()->route('admin.editor-seo'); | 221 | return redirect()->route('admin.editor-seo'); |
220 | } | 222 | } |
221 | 223 | ||
222 | public function editor_seo_destroy(SEO $page) { | 224 | public function editor_seo_destroy(SEO $page) { |
223 | $page->delete(); | 225 | $page->delete(); |
224 | return redirect()->route('admin.editor-seo'); | 226 | return redirect()->route('admin.editor-seo'); |
225 | } | 227 | } |
226 | /////////////////////////////////////////////////////////////////////// | 228 | /////////////////////////////////////////////////////////////////////// |
227 | 229 | ||
228 | /////////// кабинет - редактор страниц //////////////////////////////// | 230 | /////////// кабинет - редактор страниц //////////////////////////////// |
229 | public function editor_pages() { | 231 | public function editor_pages() { |
230 | $pages = pages::query()->OrderBy('name')->paginate(15); | 232 | $pages = pages::query()->OrderBy('name')->paginate(15); |
231 | return view('admin.pages.index', compact('pages')); | 233 | return view('admin.pages.index', compact('pages')); |
232 | } | 234 | } |
233 | 235 | ||
234 | public function editor_pages_add() { | 236 | public function editor_pages_add() { |
235 | return view('admin.pages.add'); | 237 | return view('admin.pages.add'); |
236 | } | 238 | } |
237 | 239 | ||
238 | public function editor_pages_store(PagesRequest $request) { | 240 | public function editor_pages_store(PagesRequest $request) { |
239 | $params = $request->all(); | 241 | $params = $request->all(); |
240 | if ($request->has('image')) { | 242 | if ($request->has('image')) { |
241 | $params['image'] = $request->file('image')->store('pages', 'public'); | 243 | $params['image'] = $request->file('image')->store('pages', 'public'); |
242 | } | 244 | } |
243 | 245 | ||
244 | pages::create($params); | 246 | pages::create($params); |
245 | return redirect()->route('admin.editor-pages'); | 247 | return redirect()->route('admin.editor-pages'); |
246 | } | 248 | } |
247 | 249 | ||
248 | public function editor_pages_edit(pages $page) { | 250 | public function editor_pages_edit(pages $page) { |
249 | return view('admin.pages.edit', compact('page')); | 251 | return view('admin.pages.edit', compact('page')); |
250 | } | 252 | } |
251 | 253 | ||
252 | public function editor_pages_update(PagesRequest $request, pages $page) { | 254 | public function editor_pages_update(PagesRequest $request, pages $page) { |
253 | $params = $request->all(); | 255 | $params = $request->all(); |
254 | 256 | ||
255 | if ($request->has('image')) { | 257 | if ($request->has('image')) { |
256 | if (!empty($page->image)) Storage::delete($page->image); | 258 | if (!empty($page->image)) Storage::delete($page->image); |
257 | $params['image'] = $request->file('image')->store('pages', 'public'); | 259 | $params['image'] = $request->file('image')->store('pages', 'public'); |
258 | } else { | 260 | } else { |
259 | if (!empty($page->image)) $params['image'] = $page->image; | 261 | if (!empty($page->image)) $params['image'] = $page->image; |
260 | } | 262 | } |
261 | 263 | ||
262 | $page->update($params); | 264 | $page->update($params); |
263 | return redirect()->route('admin.editor-pages'); | 265 | return redirect()->route('admin.editor-pages'); |
264 | } | 266 | } |
265 | 267 | ||
266 | public function editor_pages_destroy(pages $page) { | 268 | public function editor_pages_destroy(pages $page) { |
267 | $page->delete(); | 269 | $page->delete(); |
268 | return redirect()->route('admin.editor-pages'); | 270 | return redirect()->route('admin.editor-pages'); |
269 | } | 271 | } |
270 | /////////////////////////////////////////////////////////////////// | 272 | /////////////////////////////////////////////////////////////////// |
271 | 273 | ||
272 | ////// кабинет - реклама сайта //////////////////////////////////// | 274 | ////// кабинет - реклама сайта //////////////////////////////////// |
273 | public function reclames(Request $request) { | 275 | public function reclames(Request $request) { |
274 | if ($request->ajax()) { | 276 | if ($request->ajax()) { |
275 | $rec = reclame::find($request->id); | 277 | $rec = reclame::find($request->id); |
276 | if ($request->status == 'close') { | 278 | if ($request->status == 'close') { |
277 | $rec->is_hidden = 0; | 279 | $rec->is_hidden = 0; |
278 | } else { | 280 | } else { |
279 | $rec->is_hidden = 1; | 281 | $rec->is_hidden = 1; |
280 | } | 282 | } |
281 | $rec->save(); | 283 | $rec->save(); |
282 | } | 284 | } |
283 | 285 | ||
284 | $reclames = reclame::query()->OrderBy('title')->paginate(15); | 286 | $reclames = reclame::query()->OrderBy('title')->paginate(15); |
285 | 287 | ||
286 | if ($request->ajax()) { | 288 | if ($request->ajax()) { |
287 | return view('admin.reclames.index_ajax', compact('reclames')); | 289 | return view('admin.reclames.index_ajax', compact('reclames')); |
288 | } else { | 290 | } else { |
289 | return view('admin.reclames.index', compact('reclames')); | 291 | return view('admin.reclames.index', compact('reclames')); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | 294 | ||
293 | public function reclames_add() { | 295 | public function reclames_add() { |
294 | return view('admin.reclames.add'); | 296 | return view('admin.reclames.add'); |
295 | } | 297 | } |
296 | 298 | ||
297 | public function reclames_store(ReclameRequest $request) { | 299 | public function reclames_store(ReclameRequest $request) { |
298 | $params = $request->all(); | 300 | $params = $request->all(); |
299 | /*if('on' == $request->get('is_hidden')) { | 301 | /*if('on' == $request->get('is_hidden')) { |
300 | $params['is_hidden'] = 1; | 302 | $params['is_hidden'] = 1; |
301 | } else { | 303 | } else { |
302 | $params['is_hidden'] = 0; | 304 | $params['is_hidden'] = 0; |
303 | }*/ | 305 | }*/ |
304 | if ($request->has('image')) { | 306 | if ($request->has('image')) { |
305 | $params['image'] = $request->file('image')->store('reclames', 'public'); | 307 | $params['image'] = $request->file('image')->store('reclames', 'public'); |
306 | } | 308 | } |
307 | 309 | ||
308 | reclame::create($params); | 310 | reclame::create($params); |
309 | return redirect()->route('admin.reclames'); | 311 | return redirect()->route('admin.reclames'); |
310 | } | 312 | } |
311 | 313 | ||
312 | public function reclames_edit(reclame $reclame) { | 314 | public function reclames_edit(reclame $reclame) { |
313 | return view('admin.reclames.edit', compact('reclame')); | 315 | return view('admin.reclames.edit', compact('reclame')); |
314 | } | 316 | } |
315 | 317 | ||
316 | public function reclames_update(ReclameRequest $request, reclame $reclame) { | 318 | public function reclames_update(ReclameRequest $request, reclame $reclame) { |
317 | $params = $request->all(); | 319 | $params = $request->all(); |
318 | /*if('on' == $request->get('is_hidden')) { | 320 | /*if('on' == $request->get('is_hidden')) { |
319 | $params['is_hidden'] = 1; | 321 | $params['is_hidden'] = 1; |
320 | } else { | 322 | } else { |
321 | $params['is_hidden'] = 0; | 323 | $params['is_hidden'] = 0; |
322 | }*/ | 324 | }*/ |
323 | 325 | ||
324 | if ($request->has('image')) { | 326 | if ($request->has('image')) { |
325 | if (!empty($reclame->image)) Storage::delete($reclame->image); | 327 | if (!empty($reclame->image)) Storage::delete($reclame->image); |
326 | $params['image'] = $request->file('image')->store('reclames', 'public'); | 328 | $params['image'] = $request->file('image')->store('reclames', 'public'); |
327 | } else { | 329 | } else { |
328 | if (!empty($reclame->image)) $params['image'] = $reclame->image; | 330 | if (!empty($reclame->image)) $params['image'] = $reclame->image; |
329 | } | 331 | } |
330 | 332 | ||
331 | $reclame->update($params); | 333 | $reclame->update($params); |
332 | return redirect()->route('admin.reclames'); | 334 | return redirect()->route('admin.reclames'); |
333 | } | 335 | } |
334 | 336 | ||
335 | public function reclames_destroy(reclame $reclame) { | 337 | public function reclames_destroy(reclame $reclame) { |
336 | $reclame->delete(); | 338 | $reclame->delete(); |
337 | return redirect()->route('admin.reclames'); | 339 | return redirect()->route('admin.reclames'); |
338 | } | 340 | } |
339 | 341 | ||
340 | ///////////////////////////////////////////////////////////////// | 342 | ///////////////////////////////////////////////////////////////// |
341 | } | 343 | } |
342 | 344 |
resources/views/admin/counters_main/form.blade.php
1 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> | 1 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> |
2 | <label class="block text-sm"> | 2 | <label class="block text-sm"> |
3 | <span class="text-gray-700 dark:text-gray-400">Цифра</span> | 3 | <span class="text-gray-700 dark:text-gray-400">Цифра</span> |
4 | <input name="extra" id="extra" required | 4 | <input name="extra" id="extra" required |
5 | 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" | 5 | 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" |
6 | placeholder="Цифра" value="{{$blocks[$block_name]['extra'] ?? ''}}" | 6 | placeholder="Цифра" value="{{$blocks[$block_name]['extra'] ?? ''}}" |
7 | /> | 7 | /> |
8 | @error('extra') | 8 | @error('extra') |
9 | <span class="text-xs text-red-600 dark:text-red-400"> | 9 | <span class="text-xs text-red-600 dark:text-red-400"> |
10 | {{ $message }} | 10 | {{ $message }} |
11 | </span> | 11 | </span> |
12 | @enderror | 12 | @enderror |
13 | </label><br> | 13 | </label><br> |
14 | 14 | ||
15 | <label class="block text-sm"> | 15 | <label class="block text-sm"> |
16 | <span class="text-gray-700 dark:text-gray-400">Подзаголовок</span> | 16 | <span class="text-gray-700 dark:text-gray-400">Подзаголовок</span> |
17 | <input name="title" id="title" required | 17 | <input name="title" id="title" required |
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" | 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="{{$blocks[$block_name]['title'] ?? ''}}" | 19 | placeholder="Подзаголовок" value="{{$blocks[$block_name]['title'] ?? ''}}" |
20 | /> | 20 | /> |
21 | @error('title') | 21 | @error('title') |
22 | <span class="text-xs text-red-600 dark:text-red-400"> | 22 | <span class="text-xs text-red-600 dark:text-red-400"> |
23 | {{ $message }} | 23 | {{ $message }} |
24 | </span> | 24 | </span> |
25 | @enderror | 25 | @enderror |
26 | </label><br> | 26 | </label><br> |
27 | 27 | ||
28 | <label class="block text-sm"> | 28 | <label class="block text-sm"> |
29 | <span class="text-gray-700 dark:text-gray-400">Описание</span> | 29 | <span class="text-gray-700 dark:text-gray-400">Описание</span> |
30 | <textarea name="description" id="description" required | 30 | <textarea name="description" id="description" |
31 | 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" | 31 | 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" |
32 | placeholder="Описание" value="{{$blocks[$block_name]['description'] ?? ''}}" | 32 | placeholder="Описание" value="{{$blocks[$block_name]['description'] ?? ''}}" |
33 | >{{$blocks[$block_name]['description'] ?? ''}}</textarea> | 33 | >{{$blocks[$block_name]['description'] ?? ''}}</textarea> |
34 | @error('description') | 34 | @error('description') |
35 | <span class="text-xs text-red-600 dark:text-red-400"> | 35 | <span class="text-xs text-red-600 dark:text-red-400"> |
36 | {{ $message }} | 36 | {{ $message }} |
37 | </span> | 37 | </span> |
38 | @enderror | 38 | @enderror |
39 | </label><br> | 39 | </label><br> |
40 | 40 | ||
41 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> | 41 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> |
42 | <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"> | 42 | <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"> |
43 | Сохранить | 43 | Сохранить |
44 | </button> | 44 | </button> |
45 | </div> | 45 | </div> |
46 | 46 | ||
47 | </div> | 47 | </div> |
48 | 48 |