diff --git a/app/Http/Controllers/Admin/AreaController.php b/app/Http/Controllers/Admin/AreaController.php
index abec8e4..dda327b 100644
--- a/app/Http/Controllers/Admin/AreaController.php
+++ b/app/Http/Controllers/Admin/AreaController.php
@@ -5,8 +5,11 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\AreasRequest;
use App\Models\Area;
+use App\Models\foto_area;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\Validator;
class AreaController extends Controller
{
@@ -17,7 +20,7 @@ class AreaController extends Controller
*/
public function index()
{
- $areas = Area::query()->orderByDesc('created_at')->paginate(5);
+ $areas = Area::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(5);
return view('admin.area.index', compact('areas'));
}
@@ -31,9 +34,58 @@ class AreaController extends Controller
return view('admin.area.create');
}
+ /**
+ * Форма дополнительных картинок объекта
+ */
+ public function area_category(Area $area) {
+ return view('admin.area.add_img', compact('area'));
+ }
+
+ /**
+ * Сохранение дополнительных картинок объекта
+ */
+ public function area_add_img(Area $area, Request $request) {
+ $rules = [
+ 'foto' => 'required|min:3|max:255',
+ ];
+ $messages = [
+ 'required' => 'Укажите картинку!',
+ ];
+ $validator = Validator::make($request->all(), $rules, $messages);
+
+ if ($validator->fails()) {
+ return redirect()->route('admin.img.area', ['area' => $area->id])
+ ->withErrors($validator);
+ } else {
+ //$area->fotos()->create($request);
+ $foto_area = new foto_area();
+ $foto_area->area_id = $area->id;
+ $foto_area->foto = $request->file('foto')->store('areas', 'public');
- public function area_category() {
+ $foto_area->save();
+ //$area->fotos()->save($foto_area);
+ return redirect()->route('admin.area.edit', ['area' => $area->id]);
+ }
+ }
+ /**
+ * Удаление дополнительных картинок объектов недвижимости
+ * @param $id
+ * @param Area $area
+ */
+ public function area_del_img($id, Area $area) {
+ if (!empty($id)) {
+ $id = (int)$id;
+ $item = foto_area::find($id);
+ Storage::delete($item->foto);
+ $item->delete();
+ Session::flash('message','Картинка была успешно удалена!');
+
+ return redirect()->route('admin.area.edit', ['area' => $area->id]);
+
+ } else {
+ return redirect()->route('admin.area.edit', ['area' => $area->id]);
+ }
}
/**
diff --git a/app/Http/Controllers/Admin/CompanyAreaController.php b/app/Http/Controllers/Admin/CompanyAreaController.php
new file mode 100644
index 0000000..5e2f5a5
--- /dev/null
+++ b/app/Http/Controllers/Admin/CompanyAreaController.php
@@ -0,0 +1,106 @@
+ 'required|min:3|max:255',
+ 'telephone' => 'required|min:3|max:255',
+ ];
+ $messages = [
+ 'required' => 'Укажите обязательное поле',
+ ];
+
+ $validator = Validator::make($request->all(), $rules, $messages);
+
+ if ($validator->fails()) {
+ return redirect()->route('admin.company.edit', ['company' => 1])
+ ->withErrors($validator);
+ } else {
+ $params = $request->all();
+ $contact->update($params);
+ return redirect()->route('admin.company.show', ['company' => 1]);
+ }
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param \App\Models\Contact $contact
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy(Contact $contact)
+ {
+ //
+ }
+}
diff --git a/app/Http/Controllers/Admin/FormatAreaController.php b/app/Http/Controllers/Admin/FormatAreaController.php
new file mode 100644
index 0000000..39c3d67
--- /dev/null
+++ b/app/Http/Controllers/Admin/FormatAreaController.php
@@ -0,0 +1,86 @@
+orderByDesc('created_at')->orderByDesc('id')->paginate(5);
+ return view('admin.news.index', compact('news'));
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function create()
+ {
+ return view('admin.news.create');
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function store(Request $request)
+ {
+ $params = $request->all();
+ unset($params['foto']);
+
+ if ($request->has('foto')) {
+ $params['foto'] = $request->file('foto')->store('news', 'public');
+ }
+
+ News::create($params);
+ return redirect()->route('admin.news.index');
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @param \App\Models\News $news
+ * @return \Illuminate\Http\Response
+ */
+ public function show(News $news)
+ {
+ return view('admin.news.view', compact('news'));
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param \App\Models\News $news
+ * @return \Illuminate\Http\Response
+ */
+ public function edit(News $news)
+ {
+ return view('admin.news.edit', compact('news'));
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \App\Models\News $news
+ * @return \Illuminate\Http\Response
+ */
+ public function update(Request $request, News $news)
+ {
+ $params = $request->all();
+ unset($params['foto']);
+ if ($request->has('foto')) {
+ Storage::delete($news->foto);
+ $params['foto'] = $request->file('foto')->store('news', 'public');
+ }
+
+ $news->update($params);
+ return redirect()->route('admin.news.index');
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param \App\Models\News $news
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy(News $news)
+ {
+ if (!empty($news->foto)) {
+ Storage::delete($news->foto);
+ }
+ $news->delete();
+ return redirect()->route('admin.news.index');
+ }
+}
diff --git a/app/Http/Controllers/Admin/TypeAreaController.php b/app/Http/Controllers/Admin/TypeAreaController.php
new file mode 100644
index 0000000..099b339
--- /dev/null
+++ b/app/Http/Controllers/Admin/TypeAreaController.php
@@ -0,0 +1,86 @@
+id();
- $table->string('slug', 255);
- $table->string('title', 255);
- $table->text('text');
- $table->string('foto', 255);
+ //$table->string('slug', 255);
+ $table->string('title', 255)->nullable();
+ $table->text('text')->nullable();
+ $table->string('foto', 255)->nullable();
$table->timestamps();
});
}
diff --git a/database/migrations/2023_03_01_073135_create_contacts_table.php b/database/migrations/2023_03_01_073135_create_contacts_table.php
index aa9d400..e3a7487 100644
--- a/database/migrations/2023_03_01_073135_create_contacts_table.php
+++ b/database/migrations/2023_03_01_073135_create_contacts_table.php
@@ -29,6 +29,7 @@ return new class extends Migration
$table->string('title3', 255)->default('');
$table->text('text3')->nullable(true);
$table->integer('year')->default(15);
+ $table->text('conf')->nullable();
$table->timestamps();
});
}
diff --git a/resources/views/admin/area/add_img.blade.php b/resources/views/admin/area/add_img.blade.php
new file mode 100644
index 0000000..21bb6f3
--- /dev/null
+++ b/resources/views/admin/area/add_img.blade.php
@@ -0,0 +1,33 @@
+@extends('layout.admin', ['title' => 'Создание нового объекта'])
+
+@section('content')
+
+
+
+
+
Добавление картинки объекта недвижимости
+
+
+
+
+
Название: {{ $area->name_area }} ID: ({{ $area->id }})
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/admin/area/edit.blade.php b/resources/views/admin/area/edit.blade.php
index e4b0716..c8cc854 100644
--- a/resources/views/admin/area/edit.blade.php
+++ b/resources/views/admin/area/edit.blade.php
@@ -19,6 +19,35 @@
+
+ Дополнительные картинки
+ Добавить картинку в галерею
+
+
+
+ ID |
+ Фото |
+ Действия |
+
+
+
+ @if ($area->fotos->count())
+ @foreach($area->fotos as $img)
+
+ =$img->id?> |
+ |
+ Удалить |
+
+ @endforeach
+ @else
+
+ - |
+ - |
+ - |
+
+ @endif
+
+
diff --git a/resources/views/admin/company/edit.blade.php b/resources/views/admin/company/edit.blade.php
new file mode 100644
index 0000000..5910266
--- /dev/null
+++ b/resources/views/admin/company/edit.blade.php
@@ -0,0 +1,134 @@
+@extends('layout.admin', ['title' => 'Редактирование реквизитов компании'])
+
+@section('content')
+
+
+
+
+
+ - Главная
+ - Редактирование реквизитов компании
+
+
+
Редактирование рекзвизитов компании
+
+
+
+
+@endsection
diff --git a/resources/views/admin/company/view.blade.php b/resources/views/admin/company/view.blade.php
new file mode 100644
index 0000000..a9f4911
--- /dev/null
+++ b/resources/views/admin/company/view.blade.php
@@ -0,0 +1,60 @@
+@extends('layout.admin', ['title' => 'Настройки компании'])
+
+@section('content')
+
+
+
+
+
+ Редактировать реквизиты компании
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/admin/news/create.blade.php b/resources/views/admin/news/create.blade.php
new file mode 100644
index 0000000..0a55292
--- /dev/null
+++ b/resources/views/admin/news/create.blade.php
@@ -0,0 +1,25 @@
+@extends('layout.admin', ['title' => 'Создание новости'])
+
+@section('content')
+
+
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/admin/news/edit.blade.php b/resources/views/admin/news/edit.blade.php
new file mode 100644
index 0000000..e8c398e
--- /dev/null
+++ b/resources/views/admin/news/edit.blade.php
@@ -0,0 +1,25 @@
+@extends('layout.admin', ['title' => 'Создание новости'])
+
+@section('content')
+
+
+
+
+
Редактирование новости
+
+
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/admin/news/form.blade.php b/resources/views/admin/news/form.blade.php
new file mode 100644
index 0000000..132d344
--- /dev/null
+++ b/resources/views/admin/news/form.blade.php
@@ -0,0 +1,34 @@
+@csrf
+
+@isset($news)
+ @method('PUT')
+@endisset
+
+
+@error('title')
+{{ $message }}
+@enderror
+
+
+
+@error('text')
+{{ $message }}
+@enderror
+
+
+
+
+
+@isset($news->foto)
+
+@endisset
+
+
diff --git a/resources/views/admin/news/index.blade.php b/resources/views/admin/news/index.blade.php
new file mode 100644
index 0000000..8ac169c
--- /dev/null
+++ b/resources/views/admin/news/index.blade.php
@@ -0,0 +1,86 @@
+@extends('layout.admin', ['title' => 'Новости'])
+
+@section('content')
+
+@endsection
diff --git a/resources/views/admin/news/view.blade.php b/resources/views/admin/news/view.blade.php
new file mode 100644
index 0000000..87afccb
--- /dev/null
+++ b/resources/views/admin/news/view.blade.php
@@ -0,0 +1,38 @@
+@extends('layout.admin', ['title' => 'Просмотр новости'])
+
+@section('content')
+
+
+
+
+
+
+
+
+
+
+
+ @isset($news->foto)
+
+ @endisset
+
+
Вернуться к новостям
+
+
+
+@endsection
diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php
index b3b0c58..8cfa845 100644
--- a/resources/views/layout/admin.blade.php
+++ b/resources/views/layout/admin.blade.php
@@ -84,8 +84,8 @@
@@ -109,9 +109,9 @@