Commit f399180fcf731cdf107edd25bddaefb2aed7306f

Authored by Андрей Ларионов
1 parent d82a28f22a
Exists in master

Админка страница офисы и все сопутствующее им

Showing 12 changed files with 848 additions and 18 deletions Side-by-side Diff

app/Http/Controllers/Admin/HousesController.php
... ... @@ -4,8 +4,14 @@ namespace App\Http\Controllers\Admin;
4 4  
5 5 use App\Http\Controllers\Controller;
6 6 use App\Http\Requests\HousesRequest;
  7 +use App\Models\Area;
  8 +use App\Models\format_area;
  9 +use App\Models\foto_house;
7 10 use App\Models\House;
  11 +use App\Models\type_area;
8 12 use Illuminate\Http\Request;
  13 +use Illuminate\Support\Facades\Storage;
  14 +use Illuminate\Support\Facades\Validator;
9 15  
10 16 class HousesController extends Controller
11 17 {
... ... @@ -28,7 +34,10 @@ class HousesController extends Controller
28 34 */
29 35 public function create()
30 36 {
31   - return view('admin.houses.create');
  37 + $type_areas = type_area::all();
  38 + $format_areas = format_area::all();
  39 + $areas = Area::all();
  40 + return view('admin.houses.create', compact('areas', 'format_areas', 'type_areas'));
32 41 }
33 42  
34 43 /**
... ... @@ -40,7 +49,6 @@ class HousesController extends Controller
40 49 public function store(HousesRequest $request)
41 50 {
42 51 $params = $request->all();
43   - //unset($params['foto_main']);
44 52  
45 53 if ($request->has('foto_main')) {
46 54 $params['foto_main'] = $request->file('foto_main')->store('houses', 'public');
... ... @@ -51,6 +59,9 @@ class HousesController extends Controller
51 59 if ($request->has('floor_plan')) {
52 60 $params['floor_plan'] = $request->file('floor_plan')->store('houses', 'public');
53 61 }
  62 + if ($request->has('present')) {
  63 + $params['present'] = $request->file('present')->store('houses', 'public');
  64 + }
54 65  
55 66  
56 67 House::create($params);
... ... @@ -76,7 +87,12 @@ class HousesController extends Controller
76 87 */
77 88 public function edit(House $house)
78 89 {
79   - //
  90 + $type_areas = type_area::all();
  91 + $format_areas = format_area::all();
  92 + $areas = Area::all();
  93 + return view('admin.houses.edit',
  94 + compact('areas', 'format_areas', 'type_areas', 'house'));
  95 +
80 96 }
81 97  
82 98 /**
... ... @@ -86,9 +102,82 @@ class HousesController extends Controller
86 102 * @param \App\Models\House $house
87 103 * @return \Illuminate\Http\Response
88 104 */
89   - public function update(Request $request, House $house)
  105 + public function update(HousesRequest $request, House $house)
90 106 {
91   - //
  107 + $params = $request->all();
  108 +
  109 + if ($request->has('foto_main')) {
  110 + Storage::delete($house->foto_main);
  111 + $params['foto_main'] = $request->file('foto_main')->store('houses', 'public');
  112 + }
  113 +
  114 + if ($request->has('object_plan')) {
  115 + Storage::delete($house->object_plan);
  116 + $params['object_plan'] = $request->file('object_plan')->store('houses', 'public');
  117 + }
  118 +
  119 + if ($request->has('floor_plan')) {
  120 + Storage::delete($house->floor_plan);
  121 + $params['floor_plan'] = $request->file('floor_plan')->store('houses', 'public');
  122 + }
  123 +
  124 + if ($request->has('present')) {
  125 + Storage::delete($house->present);
  126 + $params['present'] = $request->file('present')->store('houses', 'public');
  127 + }
  128 +
  129 + $house->update($params);
  130 + return redirect()->route('admin.houses.index');
  131 + }
  132 +
  133 + /**
  134 + * Просмотр дополнительных картинок
  135 + */
  136 + public function view_images(House $house) {
  137 + return view('admin.houses.view_img', compact('house'));
  138 + }
  139 +
  140 + /**
  141 + * Добавление дополнительной картинки у офиса
  142 + * @param House $house
  143 + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
  144 + */
  145 + public function add_images(House $house) {
  146 + return view('admin.houses.add_img', compact('house'));
  147 + }
  148 +
  149 + public function add_images_store(Request $request, House $house) {
  150 + $rules = [
  151 + 'foto' => 'required|min:3|max:255',
  152 + ];
  153 + $messages = [
  154 + 'required' => 'Укажите обязательное поле',
  155 + ];
  156 +
  157 + $validator = Validator::make($request->all(), $rules, $messages);
  158 +
  159 + if ($validator->fails()) {
  160 + return redirect()->route('admin.view.images.houses', ['house' => $house->id])
  161 + ->withErrors($validator);
  162 + } else {
  163 + $images_house = new foto_house();
  164 + $images_house->house_id = $house->id;
  165 + if ($request->has('foto')) {
  166 + $images_house->foto = $request->file('foto')->store('houses', 'public');
  167 + }
  168 + $images_house->save();
  169 +
  170 + return redirect()->route('admin.view.images.houses', ['house' => $house->id]);
  171 + }
  172 + }
  173 +
  174 + public function del_images(House $house, $id)
  175 + {
  176 + if (!empty($id)) {
  177 + $images_house = foto_house::find((int)$id);
  178 + $images_house->delete();
  179 + }
  180 + return redirect()->route('admin.view.images.houses', ['house' => $house->id]);
92 181 }
93 182  
94 183 /**
... ... @@ -99,6 +188,10 @@ class HousesController extends Controller
99 188 */
100 189 public function destroy(House $house)
101 190 {
102   - //
  191 + if (!empty($house->foto_main)) {
  192 + Storage::delete($house->foto_main);
  193 + }
  194 + $house->delete();
  195 + return redirect()->route('admin.houses.index');
103 196 }
104 197 }
app/Http/Requests/HousesRequest.php
... ... @@ -13,7 +13,7 @@ class HousesRequest extends FormRequest
13 13 */
14 14 public function authorize()
15 15 {
16   - return false;
  16 + return true;
17 17 }
18 18  
19 19 /**
... ... @@ -21,10 +21,54 @@ class HousesRequest extends FormRequest
21 21 *
22 22 * @return array<string, mixed>
23 23 */
  24 + /* ['area_id', 'type_area_id', 'format_area_id', 'metro', 'color_metro', 'foto_main',
  25 + 'address', 'okrug', 'articul_area', 'format_house', 'floor', 'description_metro',
  26 + 'floor_bild', 'renter', 'uploading_area', 'electric_power', 'travel_card',
  27 + 'passing_place', 'separate_input', 'shop_windows', 'place_advertising', 'windows',
  28 + 'hood', 'central_heating', 'opening_hours', 'finishing', 'parking', 'price', 'rent_in_year',
  29 + 'rent_in_month', 'scheme_deal', 'present', 'object_plan', 'floor_plan', 'description_house',
  30 + 'map_coord', 'title', 'area', 'best', 'sos_obj', 'type_plan', 'description_2',
  31 + 'price_m2'];
  32 + */
24 33 public function rules()
25 34 {
26 35 return [
27   - //
  36 + 'title' => [
  37 + 'required',
  38 + 'min:3',
  39 + 'max:100',
  40 + ],
  41 + 'address' => [
  42 + 'required',
  43 + 'min:3',
  44 + 'max:100',
  45 + ],
  46 + 'price' => [
  47 + 'required',
  48 + 'min:1',
  49 + 'max:100',
  50 + ],
  51 + 'foto_main' => [
  52 + 'mimes:jpeg,jpg,png',
  53 + 'max:10000'
  54 + ],
28 55 ];
29 56 }
  57 +
  58 + public function messages() {
  59 + return [
  60 + 'required' => 'Поле «:attribute» обязательно для заполнения',
  61 + 'unique' => 'Такое значение поля «:attribute» уже используется',
  62 + 'min' => [
  63 + 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
  64 + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
  65 + ],
  66 + 'max' => [
  67 + 'string' => 'Поле «:attribute» должно быть не больше :max символов',
  68 + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
  69 + ],
  70 + 'mimes' => 'Файл «:attribute» должен иметь формат :values',
  71 + ];
  72 +
  73 + }
30 74 }
app/Models/House.php
... ... @@ -9,6 +9,16 @@ class House extends Model
9 9 {
10 10 use HasFactory;
11 11  
  12 + protected $fillable = ['area_id', 'type_area_id', 'format_area_id', 'metro', 'color_metro', 'foto_main',
  13 + 'address', 'okrug', 'articul_area', 'format_house', 'floor', 'description_metro',
  14 + 'floor_bild', 'renter', 'uploading_area', 'electric_power', 'travel_card',
  15 + 'passing_place', 'separate_input', 'shop_windows', 'place_advertising', 'windows',
  16 + 'hood', 'central_heating', 'opening_hours', 'finishing', 'parking', 'price', 'rent_in_year',
  17 + 'rent_in_month', 'scheme_deal', 'present', 'object_plan', 'floor_plan', 'description_house',
  18 + 'map_coord', 'title', 'area', 'best', 'sos_obj', 'type_plan', 'description_2',
  19 + 'price_m2'];
  20 +
  21 +
12 22 /*
13 23 * Связь таблицы ТИП НЕДВИЖИМОСТИ с таблицей ОФИСЫ
14 24 */
database/migrations/2023_03_01_073202_create_houses_table.php
... ... @@ -19,7 +19,7 @@ return new class extends Migration
19 19 $table->integer('type_area_id');
20 20 $table->integer('format_area_id');
21 21 $table->string('title', 255)->default('');
22   - $table->string('slug', 255)->default('');
  22 + //$table->string('slug', 255)->default('');
23 23 $table->string('metro', 255)->default('');
24 24 $table->string('color_metro', 255)->default('');
25 25 $table->string('foto_main', 255)->default('');
database/seeders/HousesTableSeeder.php
... ... @@ -19,7 +19,7 @@ class HousesTableSeeder extends Seeder
19 19 $data = [
20 20 /*1 */[
21 21 'title' => 'Индустриальная недвижимость1',
22   - 'slug' => 'Individual_nedvijimost1',
  22 + //'slug' => 'Individual_nedvijimost1',
23 23 'area_id' => 1,
24 24 'area' => 26,
25 25 'type_area_id' => 1,
... ... @@ -40,7 +40,7 @@ class HousesTableSeeder extends Seeder
40 40 ],
41 41 /*2*/[
42 42 'title' => 'Индустриальная недвижимость2',
43   - 'slug' => 'Individual_nedvijimost2',
  43 + //'slug' => 'Individual_nedvijimost2',
44 44 'area_id' => 1,
45 45 'area' => 18,
46 46 'type_area_id' => 2,
... ... @@ -61,7 +61,7 @@ class HousesTableSeeder extends Seeder
61 61 ],
62 62 /*3*/[
63 63 'title' => 'Индустриальная недвижимость3',
64   - 'slug' => 'Individual_nedvijimost3',
  64 + //'slug' => 'Individual_nedvijimost3',
65 65 'area_id' => 1,
66 66 'area' => 37,
67 67 'type_area_id' => 2,
... ... @@ -83,7 +83,7 @@ class HousesTableSeeder extends Seeder
83 83  
84 84 /*4*/[
85 85 'title' => 'Офис1',
86   - 'slug' => 'ofic1',
  86 + //'slug' => 'ofic1',
87 87 'area_id' => 1,
88 88 'area' => 34,
89 89 'type_area_id' => 2,
... ... @@ -106,7 +106,7 @@ class HousesTableSeeder extends Seeder
106 106 /*5*/
107 107 [
108 108 'title' => 'Индустриальная недвижимость5',
109   - 'slug' => 'Individual_nedvijimost5',
  109 + // 'slug' => 'Individual_nedvijimost5',
110 110 'area_id' => 2,
111 111 'area' => 16,
112 112 'type_area_id' => 2,
... ... @@ -129,7 +129,7 @@ class HousesTableSeeder extends Seeder
129 129 /*6*/
130 130 [
131 131 'title' => 'Индустриальная недвижимость6',
132   - 'slug' => 'Individual_nedvijimost6',
  132 + //'slug' => 'Individual_nedvijimost6',
133 133 'area_id' => 2,
134 134 'area' => 30,
135 135 'type_area_id' => 3,
... ... @@ -152,7 +152,7 @@ class HousesTableSeeder extends Seeder
152 152 /*7*/
153 153 [
154 154 'title' => 'Офис7',
155   - 'slug' => 'Individual_nedvijimost7',
  155 + //'slug' => 'Individual_nedvijimost7',
156 156 'area_id' => 2,
157 157 'area' => 25,
158 158 'type_area_id' => 1,
... ... @@ -175,7 +175,7 @@ class HousesTableSeeder extends Seeder
175 175 /*8*/
176 176 [
177 177 'title' => 'Индустриальная недвижимость8',
178   - 'slug' => 'Individual_nedvijimost8',
  178 + //'slug' => 'Individual_nedvijimost8',
179 179 'area_id' => 2,
180 180 'area' => 20,
181 181 'type_area_id' => 3,
... ... @@ -199,7 +199,7 @@ class HousesTableSeeder extends Seeder
199 199 foreach ($data as $item) {
200 200 $albom = new House();
201 201 $albom->title = $item['title'];
202   - $albom->slug = $item['slug'];
  202 + //$albom->slug = $item['slug'];
203 203 $albom->area_id = $item['area_id'];
204 204 $albom->area = $item['area'];
205 205 $albom->type_area_id = $item['type_area_id'];
resources/views/admin/houses/add_img.blade.php
... ... @@ -0,0 +1,31 @@
  1 +@extends('layout.admin', ['title' => 'Добавление картинки офиса'])
  2 +
  3 +@section('content')
  4 + <section class="favorites">
  5 + <div class="favorites-top">
  6 + <div class="container">
  7 + <div class="breadcrumbs">
  8 + <ul class="breadcrumbs__list">
  9 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('user.index') }}">Главная</a></li>
  10 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('admin.houses.index') }}">Офисы </a></li>
  11 + <li class="breadcrumbs__item"><span class="breadcrumbs__link">Добавление доп.картинки офиса </span></li>
  12 + </ul>
  13 + </div>
  14 + <h1 class="favorites__title title-main">Добавление доп.картинки офиса</h1>
  15 + </div>
  16 + </div>
  17 + <div class="favorites-cnt">
  18 + <div class="container">
  19 + <h3>Название: {{ $house->title }} ID: ({{ $house->id }})</h3>
  20 + <form method="post" enctype="multipart/form-data" action="{{ route('admin.add.image.post.houses', ['house' => $house->id]) }}" style="width:100%">
  21 + @csrf
  22 + <label for="foto">Файл-картинка:</label>
  23 + <input type="file" class="form-control-file txt" name="foto" id="foto" accept="image/png, image/jpeg">
  24 +
  25 + <br><br>
  26 + <button type="submit" class="btn hero-search__btn btn--main">Сохранить</button>
  27 + </form>
  28 + </div>
  29 + </div>
  30 + </section>
  31 +@endsection
resources/views/admin/houses/create.blade.php
... ... @@ -0,0 +1,25 @@
  1 +@extends('layout.admin', ['title' => 'Создание офиса'])
  2 +
  3 +@section('content')
  4 + <section class="favorites">
  5 + <div class="favorites-top">
  6 + <div class="container">
  7 + <div class="breadcrumbs">
  8 + <ul class="breadcrumbs__list">
  9 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('user.index') }}">Главная</a></li>
  10 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('admin.houses.index') }}">Офисы </a></li>
  11 + <li class="breadcrumbs__item"><span class="breadcrumbs__link">Создание офиса </span></li>
  12 + </ul>
  13 + </div>
  14 + <h1 class="favorites__title title-main">Создание офиса</h1>
  15 + </div>
  16 + </div>
  17 + <div class="favorites-cnt">
  18 + <div class="container">
  19 + <form method="post" enctype="multipart/form-data" action="{{ route('admin.houses.store') }}" style="width:100%">
  20 + @include('admin.houses.form')
  21 + </form>
  22 + </div>
  23 + </div>
  24 + </section>
  25 +@endsection
resources/views/admin/houses/edit.blade.php
... ... @@ -0,0 +1,25 @@
  1 +@extends('layout.admin', ['title' => 'Редактирование офиса'])
  2 +
  3 +@section('content')
  4 + <section class="favorites">
  5 + <div class="favorites-top">
  6 + <div class="container">
  7 + <div class="breadcrumbs">
  8 + <ul class="breadcrumbs__list">
  9 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('user.index') }}">Главная</a></li>
  10 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('admin.houses.index') }}">Офисы </a></li>
  11 + <li class="breadcrumbs__item"><span class="breadcrumbs__link">Редактирование офиса </span></li>
  12 + </ul>
  13 + </div>
  14 + <h1 class="favorites__title title-main">Редактирование офиса</h1>
  15 + </div>
  16 + </div>
  17 + <div class="favorites-cnt">
  18 + <div class="container">
  19 + <form method="post" enctype="multipart/form-data" action="{{ route('admin.houses.update', ['house' => $house->id])}}" style="width:100%">
  20 + @include('admin.houses.form')
  21 + </form>
  22 + </div>
  23 + </div>
  24 + </section>
  25 +@endsection
resources/views/admin/houses/form.blade.php
... ... @@ -0,0 +1,533 @@
  1 +@csrf
  2 +
  3 +@isset($house)
  4 + @method('PUT')
  5 +@endisset
  6 +
  7 +<label for="title">Заголовок офиса: <span class="req">*</span></label><br>
  8 +@error('title')
  9 +<div class="alert alert-danger">{{ $message }}</div>
  10 +@enderror
  11 +<input type="text" class="form-control_ txt" name="title" placeholder="Название офиса"
  12 + required maxlength="100" style="width: 80%" value="{{ old('title') ?? $house->title ?? '' }}"><br><br>
  13 +
  14 +<label for="best">Лучшее предложение: </label><br>
  15 +@error('best')
  16 +<div class="alert alert-danger">{{ $message }}</div>
  17 +@enderror
  18 +<select name="best" id="best" class="form-control">
  19 + <option value="1"
  20 + @isset($house)
  21 + @if($house->best == '1')
  22 + selected
  23 + @endif
  24 + @endisset
  25 + >Да</option>
  26 + <option value="0"
  27 + @isset($house)
  28 + @if($house->best == '0')
  29 + selected
  30 + @endif
  31 + @endisset
  32 + >Нет</option>
  33 +</select><br><br>
  34 +
  35 +<label for="area_id">Объект недвижимости (ЖК): <span class="req">*</span></label><br>
  36 +@error('area_id')
  37 +<div class="alert alert-danger">{{ $message }}</div>
  38 +@enderror
  39 +<select name="area_id" id="area_id" class="form-control">
  40 + @foreach($areas as $area)
  41 + <option value="{{ $area->id }}"
  42 + @isset($house)
  43 + @if($house->area_id == $area->id)
  44 + selected
  45 + @endif
  46 + @endisset
  47 + >{{ $area->name_area }}</option>
  48 + @endforeach
  49 +</select><br><br>
  50 +
  51 +<label for="type_area_id">Тип недвижимости: <span class="req">*</span></label><br>
  52 +@error('type_area_id')
  53 +<div class="alert alert-danger">{{ $message }}</div>
  54 +@enderror
  55 +<select name="type_area_id" id="type_area_id" class="form-control">
  56 + @foreach($type_areas as $tarea)
  57 + <option value="{{ $tarea->id }}"
  58 + @isset($house)
  59 + @if($house->type_area_id == $tarea->id)
  60 + selected
  61 + @endif
  62 + @endisset
  63 + >{{ $tarea->name_type }}</option>
  64 + @endforeach
  65 +</select><br><br>
  66 +
  67 +<label for="format_area_id">Формат недвижимости: <span class="req">*</span></label><br>
  68 +@error('format_area_id')
  69 +<div class="alert alert-danger">{{ $message }}</div>
  70 +@enderror
  71 +<select name="format_area_id" id="format_area_id" class="form-control">
  72 + @foreach($format_areas as $farea)
  73 + <option value="{{ $farea->id }}"
  74 + @isset($house)
  75 + @if($house->format_area_id == $farea->id)
  76 + selected
  77 + @endif
  78 + @endisset
  79 + >{{ $farea->name_format }}</option>
  80 + @endforeach
  81 +</select><br><br>
  82 +
  83 +<label for="metro">Метро: <span class="req">*</span></label><br>
  84 +@error('metro')
  85 +<div class="alert alert-danger">{{ $message }}</div>
  86 +@enderror
  87 +<input type="text" class="form-control_ txt" name="metro" placeholder="Название метро"
  88 + required maxlength="100" style="width: 80%" value="{{ old('metro') ?? $house->metro ?? '' }}"><br><br>
  89 +
  90 +<label for="description_metro">Удаленность метро: </label><br>
  91 +@error('description_metro')
  92 +<div class="alert alert-danger">{{ $message }}</div>
  93 +@enderror
  94 +<input type="text" class="form-control_ txt" name="description_metro" placeholder="Удаленность метро"
  95 + required maxlength="100" style="width: 80%" value="{{ old('description_metro') ?? $house->description_metro ?? '' }}"><br><br>
  96 +
  97 +<label for="address">Адрес: <span class="req">*</span></label><br>
  98 +@error('address')
  99 +<div class="alert alert-danger">{{ $message }}</div>
  100 +@enderror
  101 +<input type="text" class="form-control_ txt" name="address" placeholder="Адрес"
  102 + required maxlength="100" style="width: 80%" value="{{ old('address') ?? $house->address ?? '' }}"><br><br>
  103 +
  104 +<label for="okrug">Округ: <span class="req">*</span></label><br>
  105 +@error('okrug')
  106 +<div class="alert alert-danger">{{ $message }}</div>
  107 +@enderror
  108 +<input type="text" class="form-control_ txt" name="okrug" placeholder="Округ"
  109 + required maxlength="100" style="width: 80%" value="{{ old('okrug') ?? $house->okrug ?? '' }}"><br><br>
  110 +
  111 +<label for="foto_main">Файл-картинка:</label><br>
  112 +<input type="file" class="form-control-file txt" name="foto_main" id="foto_main" accept="image/png, image/jpeg"><br>
  113 +
  114 +@isset($house->foto_main)
  115 + <div class="form-group form-check">
  116 + <img src="<?=asset(Storage::url($house->foto_main))?>" width="100px"/>
  117 + <input type="checkbox" class="form-check-input" name="remove" id="remove">
  118 + <label class="form-check-label" for="remove">
  119 + Удалить загруженное изображение
  120 + </label>
  121 + </div>
  122 +@endisset
  123 +<br>
  124 +
  125 +<label for="articul_area">Артикул помещения: </label><br>
  126 +@error('articul_area')
  127 +<div class="alert alert-danger">{{ $message }}</div>
  128 +@enderror
  129 +<input type="text" class="form-control_ txt" name="articul_area" placeholder="Артикул помещения"
  130 + required maxlength="100" style="width: 80%" value="{{ old('articul_area') ?? $house->articul_area ?? '' }}"><br><br>
  131 +
  132 +<label for="format_house">Формат помещения: <span class="req">*</span></label><br>
  133 +@error('format_house')
  134 +<div class="alert alert-danger">{{ $message }}</div>
  135 +@enderror
  136 +<select name="format_house" id="format_house" class="form-control">
  137 + <option value="Аренда"
  138 + @isset($house)
  139 + @if($house->format_house == 'Аренда')
  140 + selected
  141 + @endif
  142 + @endisset
  143 + >Аренда</option>
  144 + <option value="Продажа"
  145 + @isset($house)
  146 + @if($house->format_house == 'Продажа')
  147 + selected
  148 + @endif
  149 + @endisset
  150 + >Продажа</option>
  151 + <option value="Бизнес"
  152 + @isset($house)
  153 + @if($house->format_house == 'Бизнес')
  154 + selected
  155 + @endif
  156 + @endisset
  157 + >Бизнес</option>
  158 + <option value="Арендованные"
  159 + @isset($house)
  160 + @if($house->format_house == 'Арендованные')
  161 + selected
  162 + @endif
  163 + @endisset
  164 + >Арендованные</option>
  165 +</select><br><br>
  166 +
  167 +<label for="area">Площадь помещения: <span class="req">*</span></label><br>
  168 +@error('area')
  169 +<div class="alert alert-danger">{{ $message }}</div>
  170 +@enderror
  171 +<input type="text" class="form-control_ txt" name="area" placeholder="Площадь помещения"
  172 + required maxlength="100" style="width: 80%" value="{{ old('area') ?? $house->area ?? '' }}"><br><br>
  173 +
  174 +<label for="floor">Этаж: </label><br>
  175 +@error('floor')
  176 +<div class="alert alert-danger">{{ $message }}</div>
  177 +@enderror
  178 +<input type="text" class="form-control_ txt" name="floor" placeholder="Этаж"
  179 + required maxlength="100" style="width: 80%" value="{{ old('floor') ?? $house->floor ?? '' }}"><br><br>
  180 +
  181 +<label for="floor_bild">Этажность здания: </label><br>
  182 +@error('floor_bild')
  183 +<div class="alert alert-danger">{{ $message }}</div>
  184 +@enderror
  185 +<input type="text" class="form-control_ txt" name="floor_bild" placeholder="Этажность здания"
  186 + required maxlength="100" style="width: 80%" value="{{ old('floor_bild') ?? $house->floor_bild ?? '' }}"><br><br>
  187 +
  188 +<label for="renter">Арендатор (поле только для аренды и арендованные): </label><br>
  189 +@error('renter')
  190 +<div class="alert alert-danger">{{ $message }}</div>
  191 +@enderror
  192 +<input type="text" class="form-control_ txt" name="renter" placeholder="Арендатор"
  193 + required maxlength="100" style="width: 80%" value="{{ old('renter') ?? $house->renter ?? '' }}"><br><br>
  194 +
  195 +<label for="price">Цена: </label><br>
  196 +@error('price')
  197 +<div class="alert alert-danger">{{ $message }}</div>
  198 +@enderror
  199 +<input type="text" class="form-control_ txt" name="price" placeholder="Цена"
  200 + required maxlength="100" style="width: 80%" value="{{ old('price') ?? $house->price ?? '' }}"><br><br>
  201 +
  202 +<label for="price_m2">Цена за метр2: </label><br>
  203 +@error('price_m2')
  204 +<div class="alert alert-danger">{{ $message }}</div>
  205 +@enderror
  206 +<input type="text" class="form-control_ txt" name="price_m2" placeholder="Цена за метр2"
  207 + required maxlength="100" style="width: 80%" value="{{ old('price_m2') ?? $house->price_m2 ?? '' }}"><br><br>
  208 +
  209 +<label for="rent_in_year">Аренда в год (поле только для аренды): </label><br>
  210 +@error('rent_in_year')
  211 +<div class="alert alert-danger">{{ $message }}</div>
  212 +@enderror
  213 +<input type="text" class="form-control_ txt" name="rent_in_year" placeholder="Аренда в год"
  214 + required maxlength="100" style="width: 80%" value="{{ old('rent_in_year') ?? $house->rent_in_year ?? '' }}"><br><br>
  215 +
  216 +<label for="description_house">Описание офиса: </label><br>
  217 +@error('description_house')
  218 +<div class="alert alert-danger">{{ $message }}</div>
  219 +@enderror
  220 +<textarea class="form-control_ txtarea ckeditor" name="description_house" placeholder="Описание офиса" required
  221 + rows="10" style="width: 80%">{{ old('description_house') ?? $area->description_house ?? '' }}</textarea><br><br>
  222 +
  223 +<label for="object_plan">План-объекта (картинка):</label><br>
  224 +<input type="file" class="form-control-file txt" name="object_plan" id="object_plan" accept="image/png, image/jpeg">
  225 +
  226 +@isset($house->object_plan)
  227 + <div class="form-group form-check">
  228 + <img src="<?=asset(Storage::url($house->object_plan))?>" width="100px"/>
  229 + </div>
  230 +@endisset
  231 +<br><br>
  232 +
  233 +<label for="floor_plan">План-этажа (картинка):</label><br>
  234 +<input type="file" class="form-control-file txt" name="floor_plan" id="floor_plan" accept="image/png, image/jpeg">
  235 +
  236 +@isset($house->floor_plan)
  237 + <div class="form-group form-check">
  238 + <img src="<?=asset(Storage::url($house->floor_plan))?>" width="100px"/>
  239 + </div>
  240 +@endisset
  241 +<br><br>
  242 +
  243 +<label for="present">Презентация:</label><br>
  244 +<input type="file" class="form-control-file txt" name="present" id="present">
  245 +
  246 +@isset($house->present)
  247 + <div class="form-group form-check">
  248 + <a href="<?=asset(Storage::url($house->floor_plan))?>">Презентация</a>
  249 + </div>
  250 +@endisset
  251 +<br><br>
  252 +
  253 +<label for="unloading_area">Зона разгрузки: </label><br>
  254 +@error('unloading_area')
  255 +<div class="alert alert-danger">{{ $message }}</div>
  256 +@enderror
  257 +<select name="unloading_area" id="unloading_area" class="form-control">
  258 + <option value="1"
  259 + @isset($house)
  260 + @if($house->unloading_area == '1')
  261 + selected
  262 + @endif
  263 + @endisset
  264 + >Есть</option>
  265 + <option value="0"
  266 + @isset($house)
  267 + @if($house->unloading_area == '0')
  268 + selected
  269 + @endif
  270 + @endisset
  271 + >Нет</option>
  272 +</select><br><br>
  273 +
  274 +<label for="electric_power">Электрическая мощность: </label><br>
  275 +@error('electric_power')
  276 +<div class="alert alert-danger">{{ $message }}</div>
  277 +@enderror
  278 +<input type="text" class="form-control_ txt" name="electric_power" placeholder="Электрическая мощность"
  279 + required maxlength="100" style="width: 80%" value="{{ old('electric_power') ?? $house->electric_power ?? '' }}"><br><br>
  280 +
  281 +<label for="travel_card">Проездное место: </label><br>
  282 +@error('travel_card')
  283 +<div class="alert alert-danger">{{ $message }}</div>
  284 +@enderror
  285 +<select name="travel_card" id="travel_card" class="form-control">
  286 + <option value="1"
  287 + @isset($house)
  288 + @if($house->travel_card == '1')
  289 + selected
  290 + @endif
  291 + @endisset
  292 + >Да</option>
  293 + <option value="0"
  294 + @isset($house)
  295 + @if($house->travel_card == '0')
  296 + selected
  297 + @endif
  298 + @endisset
  299 + >Нет</option>
  300 +</select><br><br>
  301 +
  302 +<label for="passing_place">Проходное место: </label><br>
  303 +@error('passing_place')
  304 +<div class="alert alert-danger">{{ $message }}</div>
  305 +@enderror
  306 +<select name="passing_place" id="passing_place" class="form-control">
  307 + <option value="1"
  308 + @isset($house)
  309 + @if($house->passing_place == '1')
  310 + selected
  311 + @endif
  312 + @endisset
  313 + >Да</option>
  314 + <option value="0"
  315 + @isset($house)
  316 + @if($house->passing_place == '0')
  317 + selected
  318 + @endif
  319 + @endisset
  320 + >Нет</option>
  321 +</select><br><br>
  322 +
  323 +<label for="separate_input">Отдельный вход: </label><br>
  324 +@error('separate_input')
  325 +<div class="alert alert-danger">{{ $message }}</div>
  326 +@enderror
  327 +<select name="separate_input" id="separate_input" class="form-control">
  328 + <option value="1"
  329 + @isset($house)
  330 + @if($house->separate_input == '1')
  331 + selected
  332 + @endif
  333 + @endisset
  334 + >Да</option>
  335 + <option value="0"
  336 + @isset($house)
  337 + @if($house->separate_input == '0')
  338 + selected
  339 + @endif
  340 + @endisset
  341 + >Нет</option>
  342 +</select><br><br>
  343 +
  344 +<label for="shop_windows">Витрины: </label><br>
  345 +@error('shop_windows')
  346 +<div class="alert alert-danger">{{ $message }}</div>
  347 +@enderror
  348 +<select name="shop_windows" id="shop_windows" class="form-control">
  349 + <option value="1"
  350 + @isset($house)
  351 + @if($house->shop_windows == '1')
  352 + selected
  353 + @endif
  354 + @endisset
  355 + >Да</option>
  356 + <option value="0"
  357 + @isset($house)
  358 + @if($house->shop_windows == '0')
  359 + selected
  360 + @endif
  361 + @endisset
  362 + >Нет</option>
  363 +</select><br><br>
  364 +
  365 +<label for="place_advertising">Место для рекламы: </label><br>
  366 +@error('place_advertising')
  367 +<div class="alert alert-danger">{{ $message }}</div>
  368 +@enderror
  369 +<select name="place_advertising" id="place_advertising" class="form-control">
  370 + <option value="1"
  371 + @isset($house)
  372 + @if($house->place_advertising == '1')
  373 + selected
  374 + @endif
  375 + @endisset
  376 + >Да</option>
  377 + <option value="0"
  378 + @isset($house)
  379 + @if($house->place_advertising == '0')
  380 + selected
  381 + @endif
  382 + @endisset
  383 + >Нет</option>
  384 +</select><br><br>
  385 +
  386 +<label for="windows">Окна: </label><br>
  387 +@error('windows')
  388 +<div class="alert alert-danger">{{ $message }}</div>
  389 +@enderror
  390 +<input type="text" class="form-control_ txt" name="windows" placeholder="Окна"
  391 + required maxlength="100" style="width: 80%" value="{{ old('windows') ?? $house->windows ?? '' }}"><br><br>
  392 +
  393 +<label for="hood">Вытяжка: </label><br>
  394 +@error('hood')
  395 +<div class="alert alert-danger">{{ $message }}</div>
  396 +@enderror
  397 +<select name="hood" id="hood" class="form-control">
  398 + <option value="1"
  399 + @isset($house)
  400 + @if($house->hood == '1')
  401 + selected
  402 + @endif
  403 + @endisset
  404 + >Да</option>
  405 + <option value="0"
  406 + @isset($house)
  407 + @if($house->hood == '0')
  408 + selected
  409 + @endif
  410 + @endisset
  411 + >Нет</option>
  412 +</select><br><br>
  413 +
  414 +<label for="central_heating">Центральное отопление: </label><br>
  415 +@error('central_heating')
  416 +<div class="alert alert-danger">{{ $message }}</div>
  417 +@enderror
  418 +<select name="central_heating" id="central_heating" class="form-control">
  419 + <option value="1"
  420 + @isset($house)
  421 + @if($house->central_heating == '1')
  422 + selected
  423 + @endif
  424 + @endisset
  425 + >Да</option>
  426 + <option value="0"
  427 + @isset($house)
  428 + @if($house->central_heating == '0')
  429 + selected
  430 + @endif
  431 + @endisset
  432 + >Нет</option>
  433 +</select><br><br>
  434 +
  435 +<label for="opening_hours">Возможные часы работы: </label><br>
  436 +@error('opening_hours')
  437 +<div class="alert alert-danger">{{ $message }}</div>
  438 +@enderror
  439 +<input type="text" class="form-control_ txt" name="opening_hours" placeholder="Возможные часы работы"
  440 + required maxlength="100" style="width: 80%" value="{{ old('opening_hours') ?? $house->opening_hours ?? '' }}"><br><br>
  441 +
  442 +<label for="finishing">Отделка: </label><br>
  443 +@error('finishing')
  444 +<div class="alert alert-danger">{{ $message }}</div>
  445 +@enderror
  446 +<select name="finishing" id="finishing" class="form-control">
  447 + <option value="1"
  448 + @isset($house)
  449 + @if($house->finishing == '1')
  450 + selected
  451 + @endif
  452 + @endisset
  453 + >Да</option>
  454 + <option value="0"
  455 + @isset($house)
  456 + @if($house->finishing == '0')
  457 + selected
  458 + @endif
  459 + @endisset
  460 + >Нет</option>
  461 +</select><br><br>
  462 +
  463 +<label for="parking">Парковка (кол-во мест): </label><br>
  464 +@error('parking')
  465 +<div class="alert alert-danger">{{ $message }}</div>
  466 +@enderror
  467 +<input type="text" class="form-control_ txt" name="parking" placeholder="Парковка"
  468 + required maxlength="100" style="width: 80%" value="{{ old('parking') ?? $house->parking ?? '' }}"><br><br>
  469 +
  470 +<label for="scheme_deal">Схема сделки: </label><br>
  471 +@error('scheme_deal')
  472 +<div class="alert alert-danger">{{ $message }}</div>
  473 +@enderror
  474 +<input type="text" class="form-control_ txt" name="scheme_deal" placeholder="Схема сделки"
  475 + required maxlength="100" style="width: 80%" value="{{ old('scheme_deal') ?? $house->scheme_deal ?? '' }}"><br><br>
  476 +
  477 +<label for="map_coord">Координаты дома: </label><br>
  478 +<input type="text" class="form-control_ txt" name="map_coord" placeholder="Координаты дома"
  479 + required maxlength="100" value="{{ old('map_coord') ?? $house->map_coord ?? '' }}"><br><br>
  480 +
  481 +<label for="sos_obj">Состояние объекта: </label><br>
  482 +@error('sos_obj')
  483 +<div class="alert alert-danger">{{ $message }}</div>
  484 +@enderror
  485 +<select name="sos_obj" id="sos_obj" class="form-control">
  486 + <option value="Рабочее"
  487 + @isset($house)
  488 + @if($house->sos_obj == 'Рабочее')
  489 + selected
  490 + @endif
  491 + @endisset
  492 + >Рабочее</option>
  493 + <option value="Не рабочее"
  494 + @isset($house)
  495 + @if($house->sos_obj == 'Не рабочее')
  496 + selected
  497 + @endif
  498 + @endisset
  499 + >Не рабочее</option>
  500 +</select><br><br>
  501 +
  502 +<label for="type_plan">Тип планировки: </label><br>
  503 +@error('type_plan')
  504 +<div class="alert alert-danger">{{ $message }}</div>
  505 +@enderror
  506 +<select name="type_plan" id="type_plan" class="form-control">
  507 + <option value="Открытая"
  508 + @isset($house)
  509 + @if($house->type_plan == 'Открытая')
  510 + selected
  511 + @endif
  512 + @endisset
  513 + >Открытая</option>
  514 + <option value="Закрытая"
  515 + @isset($house)
  516 + @if($house->type_plan == 'Закрытая')
  517 + selected
  518 + @endif
  519 + @endisset
  520 + >Закрытая</option>
  521 +</select><br><br>
  522 +
  523 +<label for="description_2">Описание офиса дополнительно: </label><br>
  524 +@error('description_2')
  525 +<div class="alert alert-danger">{{ $message }}</div>
  526 +@enderror
  527 +<textarea class="form-control_ txtarea ckeditor" name="description_2" placeholder="Описание офиса дополнительно" required
  528 + rows="10" style="width: 80%">{{ old('description_2') ?? $house->description_2 ?? '' }}</textarea><br><br>
  529 +
  530 +<br>
  531 +<button type="submit" class="btn hero-search__btn btn--main">Сохранить</button>
  532 +
  533 +
resources/views/admin/houses/index.blade.php
... ... @@ -47,6 +47,10 @@
47 47 <a href="{{ route('admin.houses.edit', ['house' => $house->id]) }}">
48 48 Редактировать
49 49 </a> |
  50 + <a href="{{ route('admin.view.images.houses', ['house' => $house->id]) }}">
  51 + Доп.картинки
  52 + </a> |
  53 +
50 54 @csrf
51 55 @method('DELETE')
52 56 <input class=" btn-danger" type="submit" value="Удалить">
resources/views/admin/houses/view_img.blade.php
... ... @@ -0,0 +1,53 @@
  1 +@extends('layout.admin', ['title' => 'Дополнительные картинки офиса'])
  2 +
  3 +@section('content')
  4 + <section class="favorites">
  5 + <div class="favorites-top">
  6 + <div class="container">
  7 + <div class="breadcrumbs">
  8 + <ul class="breadcrumbs__list">
  9 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('user.index') }}">Главная</a></li>
  10 + <li class="breadcrumbs__item"><a class="breadcrumbs__link" href="{{ route('admin.houses.index') }}">Офисы </a></li>
  11 + <li class="breadcrumbs__item"><span class="breadcrumbs__link">Дополнительные картинки офиса </span></li>
  12 + </ul>
  13 + </div>
  14 + <h1 class="favorites__title title-main">Дополнительные картинки офиса</h1>
  15 + </div>
  16 + </div>
  17 + <div class="favorites-cnt">
  18 + <div class="container">
  19 + <h3>ID: {{$house->id}} Название офиса: {{$house->title}}</h3><br><br>
  20 + <h3>Дополнительные картинки</h3><br>
  21 + <a class="btn hero-search__btn btn--main" href="{{ route ('admin.add.images.houses', ['house' => $house->id]) }}">Добавить картинку в галерею</a><br><br>
  22 +
  23 + <table class="table" style="width: 100%">
  24 + <thead>
  25 + <tr>
  26 + <th>ID</th>
  27 + <th>Фото</th>
  28 + <th>Действия</th>
  29 + </tr>
  30 + </thead>
  31 + <tbody>
  32 + @if ($house->fotohouse->count())
  33 + @foreach($house->fotohouse as $img)
  34 + <tr>
  35 + <td><?=$img->id?></td>
  36 + <td><img src="<?=asset(Storage::url($img->foto))?>" width="100px"/></td>
  37 + <td><a href="{{ route('admin.del.images.houses', ['id'=> $img->id, 'house' => $house->id]) }}">Удалить</a></td>
  38 + </tr>
  39 + @endforeach
  40 + @else
  41 + <tr>
  42 + <td>-</td>
  43 + <td>-</td>
  44 + <td>-</td>
  45 + </tr>
  46 + @endif
  47 + </tbody>
  48 + </table>
  49 + </div>
  50 + </div>
  51 + </section>
  52 +@endsection
  53 +
... ... @@ -193,4 +193,16 @@ Route::group([
193 193 */
194 194 Route::resource('houses', HousesController::class, ['except' => ['show']]);
195 195  
  196 + // просмотр дополнительных картинок офиса
  197 + Route::get('houses/{house}/images', [HousesController::class, 'view_images'])->name('view.images.houses');
  198 +
  199 + // форма добавление дополнительной картинки офиса
  200 + Route::get('houses/{house}/add/images', [HousesController::class, 'add_images'])->name('add.images.houses');
  201 +
  202 + // добавление дополнительной картинки офиса
  203 + Route::post('houses/{house}/add/images', [HousesController::class, 'add_images_store'])->name('add.image.post.houses');
  204 +
  205 + // удаление дополнительной картинки офиса
  206 + Route::get('houses/{house}/del/{id}/images', [HousesController::class, 'del_images'])->name('del.images.houses');
  207 +
196 208 });