Commit 3575d19ae609a1347c12388accf62c076f9efcea

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

Админка новости и страница компании

Showing 21 changed files with 1117 additions and 14 deletions Side-by-side Diff

app/Http/Controllers/Admin/AreaController.php
... ... @@ -5,8 +5,11 @@ namespace App\Http\Controllers\Admin;
5 5 use App\Http\Controllers\Controller;
6 6 use App\Http\Requests\AreasRequest;
7 7 use App\Models\Area;
  8 +use App\Models\foto_area;
8 9 use Illuminate\Http\Request;
  10 +use Illuminate\Support\Facades\Session;
9 11 use Illuminate\Support\Facades\Storage;
  12 +use Illuminate\Support\Facades\Validator;
10 13  
11 14 class AreaController extends Controller
12 15 {
... ... @@ -17,7 +20,7 @@ class AreaController extends Controller
17 20 */
18 21 public function index()
19 22 {
20   - $areas = Area::query()->orderByDesc('created_at')->paginate(5);
  23 + $areas = Area::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(5);
21 24 return view('admin.area.index', compact('areas'));
22 25 }
23 26  
... ... @@ -31,9 +34,58 @@ class AreaController extends Controller
31 34 return view('admin.area.create');
32 35 }
33 36  
  37 + /**
  38 + * Форма дополнительных картинок объекта
  39 + */
  40 + public function area_category(Area $area) {
  41 + return view('admin.area.add_img', compact('area'));
  42 + }
  43 +
  44 + /**
  45 + * Сохранение дополнительных картинок объекта
  46 + */
  47 + public function area_add_img(Area $area, Request $request) {
  48 + $rules = [
  49 + 'foto' => 'required|min:3|max:255',
  50 + ];
  51 + $messages = [
  52 + 'required' => 'Укажите картинку!',
  53 + ];
  54 + $validator = Validator::make($request->all(), $rules, $messages);
  55 +
  56 + if ($validator->fails()) {
  57 + return redirect()->route('admin.img.area', ['area' => $area->id])
  58 + ->withErrors($validator);
  59 + } else {
  60 + //$area->fotos()->create($request);
  61 + $foto_area = new foto_area();
  62 + $foto_area->area_id = $area->id;
  63 + $foto_area->foto = $request->file('foto')->store('areas', 'public');
34 64  
35   - public function area_category() {
  65 + $foto_area->save();
  66 + //$area->fotos()->save($foto_area);
  67 + return redirect()->route('admin.area.edit', ['area' => $area->id]);
  68 + }
  69 + }
36 70  
  71 + /**
  72 + * Удаление дополнительных картинок объектов недвижимости
  73 + * @param $id
  74 + * @param Area $area
  75 + */
  76 + public function area_del_img($id, Area $area) {
  77 + if (!empty($id)) {
  78 + $id = (int)$id;
  79 + $item = foto_area::find($id);
  80 + Storage::delete($item->foto);
  81 + $item->delete();
  82 + Session::flash('message','Картинка была успешно удалена!');
  83 +
  84 + return redirect()->route('admin.area.edit', ['area' => $area->id]);
  85 +
  86 + } else {
  87 + return redirect()->route('admin.area.edit', ['area' => $area->id]);
  88 + }
37 89 }
38 90  
39 91 /**
app/Http/Controllers/Admin/CompanyAreaController.php
... ... @@ -0,0 +1,106 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\Contact;
  7 +use Illuminate\Http\Request;
  8 +use Illuminate\Support\Facades\Validator;
  9 +
  10 +class CompanyAreaController extends Controller
  11 +{
  12 + /**
  13 + * Display a listing of the resource.
  14 + *
  15 + * @return \Illuminate\Http\Response
  16 + */
  17 + public function index()
  18 + {
  19 + //
  20 + }
  21 +
  22 + /**
  23 + * Show the form for creating a new resource.
  24 + *
  25 + * @return \Illuminate\Http\Response
  26 + */
  27 + public function create()
  28 + {
  29 + //
  30 + }
  31 +
  32 + /**
  33 + * Store a newly created resource in storage.
  34 + *
  35 + * @param \Illuminate\Http\Request $request
  36 + * @return \Illuminate\Http\Response
  37 + */
  38 + public function store(Request $request)
  39 + {
  40 + //
  41 + }
  42 +
  43 + /**
  44 + * Display the specified resource.
  45 + *
  46 + * @param \App\Models\Contact $contact
  47 + * @return \Illuminate\Http\Response
  48 + */
  49 + public function show(Contact $contact)
  50 + {
  51 + $firm_data = Contact::find(1);
  52 + return view('admin.company.view', compact('firm_data'));
  53 + }
  54 +
  55 + /**
  56 + * Show the form for editing the specified resource.
  57 + *
  58 + * @param \App\Models\Contact $contact
  59 + * @return \Illuminate\Http\Response
  60 + */
  61 + public function edit(Contact $contact)
  62 + {
  63 + $firm_data = Contact::find(1);
  64 + return view('admin.company.edit', compact('firm_data'));
  65 + }
  66 +
  67 + /**
  68 + * Update the specified resource in storage.
  69 + *
  70 + * @param \Illuminate\Http\Request $request
  71 + * @param \App\Models\Contact $contact
  72 + * @return \Illuminate\Http\Response
  73 + */
  74 + public function update(Request $request, Contact $contact)
  75 + {
  76 + $rules = [
  77 + 'email' => 'required|min:3|max:255',
  78 + 'telephone' => 'required|min:3|max:255',
  79 + ];
  80 + $messages = [
  81 + 'required' => 'Укажите обязательное поле',
  82 + ];
  83 +
  84 + $validator = Validator::make($request->all(), $rules, $messages);
  85 +
  86 + if ($validator->fails()) {
  87 + return redirect()->route('admin.company.edit', ['company' => 1])
  88 + ->withErrors($validator);
  89 + } else {
  90 + $params = $request->all();
  91 + $contact->update($params);
  92 + return redirect()->route('admin.company.show', ['company' => 1]);
  93 + }
  94 + }
  95 +
  96 + /**
  97 + * Remove the specified resource from storage.
  98 + *
  99 + * @param \App\Models\Contact $contact
  100 + * @return \Illuminate\Http\Response
  101 + */
  102 + public function destroy(Contact $contact)
  103 + {
  104 + //
  105 + }
  106 +}
app/Http/Controllers/Admin/FormatAreaController.php
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\format_area;
  7 +use Illuminate\Http\Request;
  8 +
  9 +class FormatAreaController extends Controller
  10 +{
  11 + /**
  12 + * Display a listing of the resource.
  13 + *
  14 + * @return \Illuminate\Http\Response
  15 + */
  16 + public function index()
  17 + {
  18 + //
  19 + }
  20 +
  21 + /**
  22 + * Show the form for creating a new resource.
  23 + *
  24 + * @return \Illuminate\Http\Response
  25 + */
  26 + public function create()
  27 + {
  28 + //
  29 + }
  30 +
  31 + /**
  32 + * Store a newly created resource in storage.
  33 + *
  34 + * @param \Illuminate\Http\Request $request
  35 + * @return \Illuminate\Http\Response
  36 + */
  37 + public function store(Request $request)
  38 + {
  39 + //
  40 + }
  41 +
  42 + /**
  43 + * Display the specified resource.
  44 + *
  45 + * @param \App\Models\format_area $format_area
  46 + * @return \Illuminate\Http\Response
  47 + */
  48 + public function show(format_area $format_area)
  49 + {
  50 + //
  51 + }
  52 +
  53 + /**
  54 + * Show the form for editing the specified resource.
  55 + *
  56 + * @param \App\Models\format_area $format_area
  57 + * @return \Illuminate\Http\Response
  58 + */
  59 + public function edit(format_area $format_area)
  60 + {
  61 + //
  62 + }
  63 +
  64 + /**
  65 + * Update the specified resource in storage.
  66 + *
  67 + * @param \Illuminate\Http\Request $request
  68 + * @param \App\Models\format_area $format_area
  69 + * @return \Illuminate\Http\Response
  70 + */
  71 + public function update(Request $request, format_area $format_area)
  72 + {
  73 + //
  74 + }
  75 +
  76 + /**
  77 + * Remove the specified resource from storage.
  78 + *
  79 + * @param \App\Models\format_area $format_area
  80 + * @return \Illuminate\Http\Response
  81 + */
  82 + public function destroy(format_area $format_area)
  83 + {
  84 + //
  85 + }
  86 +}
app/Http/Controllers/Admin/HousesController.php
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\House;
  7 +use Illuminate\Http\Request;
  8 +
  9 +class HousesController extends Controller
  10 +{
  11 + /**
  12 + * Display a listing of the resource.
  13 + *
  14 + * @return \Illuminate\Http\Response
  15 + */
  16 + public function index()
  17 + {
  18 + //
  19 + }
  20 +
  21 + /**
  22 + * Show the form for creating a new resource.
  23 + *
  24 + * @return \Illuminate\Http\Response
  25 + */
  26 + public function create()
  27 + {
  28 + //
  29 + }
  30 +
  31 + /**
  32 + * Store a newly created resource in storage.
  33 + *
  34 + * @param \Illuminate\Http\Request $request
  35 + * @return \Illuminate\Http\Response
  36 + */
  37 + public function store(Request $request)
  38 + {
  39 + //
  40 + }
  41 +
  42 + /**
  43 + * Display the specified resource.
  44 + *
  45 + * @param \App\Models\House $house
  46 + * @return \Illuminate\Http\Response
  47 + */
  48 + public function show(House $house)
  49 + {
  50 + //
  51 + }
  52 +
  53 + /**
  54 + * Show the form for editing the specified resource.
  55 + *
  56 + * @param \App\Models\House $house
  57 + * @return \Illuminate\Http\Response
  58 + */
  59 + public function edit(House $house)
  60 + {
  61 + //
  62 + }
  63 +
  64 + /**
  65 + * Update the specified resource in storage.
  66 + *
  67 + * @param \Illuminate\Http\Request $request
  68 + * @param \App\Models\House $house
  69 + * @return \Illuminate\Http\Response
  70 + */
  71 + public function update(Request $request, House $house)
  72 + {
  73 + //
  74 + }
  75 +
  76 + /**
  77 + * Remove the specified resource from storage.
  78 + *
  79 + * @param \App\Models\House $house
  80 + * @return \Illuminate\Http\Response
  81 + */
  82 + public function destroy(House $house)
  83 + {
  84 + //
  85 + }
  86 +}
app/Http/Controllers/Admin/MessageAreaController.php
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\ModelMailFeedback;
  7 +use Illuminate\Http\Request;
  8 +
  9 +class MessageAreaController extends Controller
  10 +{
  11 + /**
  12 + * Display a listing of the resource.
  13 + *
  14 + * @return \Illuminate\Http\Response
  15 + */
  16 + public function index()
  17 + {
  18 + //
  19 + }
  20 +
  21 + /**
  22 + * Show the form for creating a new resource.
  23 + *
  24 + * @return \Illuminate\Http\Response
  25 + */
  26 + public function create()
  27 + {
  28 + //
  29 + }
  30 +
  31 + /**
  32 + * Store a newly created resource in storage.
  33 + *
  34 + * @param \Illuminate\Http\Request $request
  35 + * @return \Illuminate\Http\Response
  36 + */
  37 + public function store(Request $request)
  38 + {
  39 + //
  40 + }
  41 +
  42 + /**
  43 + * Display the specified resource.
  44 + *
  45 + * @param \App\Models\ModelMailFeedback $modelMailFeedback
  46 + * @return \Illuminate\Http\Response
  47 + */
  48 + public function show(ModelMailFeedback $modelMailFeedback)
  49 + {
  50 + //
  51 + }
  52 +
  53 + /**
  54 + * Show the form for editing the specified resource.
  55 + *
  56 + * @param \App\Models\ModelMailFeedback $modelMailFeedback
  57 + * @return \Illuminate\Http\Response
  58 + */
  59 + public function edit(ModelMailFeedback $modelMailFeedback)
  60 + {
  61 + //
  62 + }
  63 +
  64 + /**
  65 + * Update the specified resource in storage.
  66 + *
  67 + * @param \Illuminate\Http\Request $request
  68 + * @param \App\Models\ModelMailFeedback $modelMailFeedback
  69 + * @return \Illuminate\Http\Response
  70 + */
  71 + public function update(Request $request, ModelMailFeedback $modelMailFeedback)
  72 + {
  73 + //
  74 + }
  75 +
  76 + /**
  77 + * Remove the specified resource from storage.
  78 + *
  79 + * @param \App\Models\ModelMailFeedback $modelMailFeedback
  80 + * @return \Illuminate\Http\Response
  81 + */
  82 + public function destroy(ModelMailFeedback $modelMailFeedback)
  83 + {
  84 + //
  85 + }
  86 +}
app/Http/Controllers/Admin/NewsController.php
... ... @@ -0,0 +1,108 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\News;
  7 +use Illuminate\Http\Request;
  8 +use Illuminate\Support\Facades\Storage;
  9 +
  10 +class NewsController extends Controller
  11 +{
  12 + /**
  13 + * Display a listing of the resource.
  14 + *
  15 + * @return \Illuminate\Http\Response
  16 + */
  17 + public function index()
  18 + {
  19 + $news = News::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(5);
  20 + return view('admin.news.index', compact('news'));
  21 + }
  22 +
  23 + /**
  24 + * Show the form for creating a new resource.
  25 + *
  26 + * @return \Illuminate\Http\Response
  27 + */
  28 + public function create()
  29 + {
  30 + return view('admin.news.create');
  31 + }
  32 +
  33 + /**
  34 + * Store a newly created resource in storage.
  35 + *
  36 + * @param \Illuminate\Http\Request $request
  37 + * @return \Illuminate\Http\Response
  38 + */
  39 + public function store(Request $request)
  40 + {
  41 + $params = $request->all();
  42 + unset($params['foto']);
  43 +
  44 + if ($request->has('foto')) {
  45 + $params['foto'] = $request->file('foto')->store('news', 'public');
  46 + }
  47 +
  48 + News::create($params);
  49 + return redirect()->route('admin.news.index');
  50 + }
  51 +
  52 + /**
  53 + * Display the specified resource.
  54 + *
  55 + * @param \App\Models\News $news
  56 + * @return \Illuminate\Http\Response
  57 + */
  58 + public function show(News $news)
  59 + {
  60 + return view('admin.news.view', compact('news'));
  61 + }
  62 +
  63 + /**
  64 + * Show the form for editing the specified resource.
  65 + *
  66 + * @param \App\Models\News $news
  67 + * @return \Illuminate\Http\Response
  68 + */
  69 + public function edit(News $news)
  70 + {
  71 + return view('admin.news.edit', compact('news'));
  72 + }
  73 +
  74 + /**
  75 + * Update the specified resource in storage.
  76 + *
  77 + * @param \Illuminate\Http\Request $request
  78 + * @param \App\Models\News $news
  79 + * @return \Illuminate\Http\Response
  80 + */
  81 + public function update(Request $request, News $news)
  82 + {
  83 + $params = $request->all();
  84 + unset($params['foto']);
  85 + if ($request->has('foto')) {
  86 + Storage::delete($news->foto);
  87 + $params['foto'] = $request->file('foto')->store('news', 'public');
  88 + }
  89 +
  90 + $news->update($params);
  91 + return redirect()->route('admin.news.index');
  92 + }
  93 +
  94 + /**
  95 + * Remove the specified resource from storage.
  96 + *
  97 + * @param \App\Models\News $news
  98 + * @return \Illuminate\Http\Response
  99 + */
  100 + public function destroy(News $news)
  101 + {
  102 + if (!empty($news->foto)) {
  103 + Storage::delete($news->foto);
  104 + }
  105 + $news->delete();
  106 + return redirect()->route('admin.news.index');
  107 + }
  108 +}
app/Http/Controllers/Admin/TypeAreaController.php
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Admin;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use App\Models\type_area;
  7 +use Illuminate\Http\Request;
  8 +
  9 +class TypeAreaController extends Controller
  10 +{
  11 + /**
  12 + * Display a listing of the resource.
  13 + *
  14 + * @return \Illuminate\Http\Response
  15 + */
  16 + public function index()
  17 + {
  18 + //
  19 + }
  20 +
  21 + /**
  22 + * Show the form for creating a new resource.
  23 + *
  24 + * @return \Illuminate\Http\Response
  25 + */
  26 + public function create()
  27 + {
  28 + //
  29 + }
  30 +
  31 + /**
  32 + * Store a newly created resource in storage.
  33 + *
  34 + * @param \Illuminate\Http\Request $request
  35 + * @return \Illuminate\Http\Response
  36 + */
  37 + public function store(Request $request)
  38 + {
  39 + //
  40 + }
  41 +
  42 + /**
  43 + * Display the specified resource.
  44 + *
  45 + * @param \App\Models\type_area $type_area
  46 + * @return \Illuminate\Http\Response
  47 + */
  48 + public function show(type_area $type_area)
  49 + {
  50 + //
  51 + }
  52 +
  53 + /**
  54 + * Show the form for editing the specified resource.
  55 + *
  56 + * @param \App\Models\type_area $type_area
  57 + * @return \Illuminate\Http\Response
  58 + */
  59 + public function edit(type_area $type_area)
  60 + {
  61 + //
  62 + }
  63 +
  64 + /**
  65 + * Update the specified resource in storage.
  66 + *
  67 + * @param \Illuminate\Http\Request $request
  68 + * @param \App\Models\type_area $type_area
  69 + * @return \Illuminate\Http\Response
  70 + */
  71 + public function update(Request $request, type_area $type_area)
  72 + {
  73 + //
  74 + }
  75 +
  76 + /**
  77 + * Remove the specified resource from storage.
  78 + *
  79 + * @param \App\Models\type_area $type_area
  80 + * @return \Illuminate\Http\Response
  81 + */
  82 + public function destroy(type_area $type_area)
  83 + {
  84 + //
  85 + }
  86 +}
... ... @@ -8,4 +8,7 @@ use Illuminate\Database\Eloquent\Model;
8 8 class News extends Model
9 9 {
10 10 use HasFactory;
  11 +
  12 + protected $fillable = ['title', 'text', 'foto'];
  13 +
11 14 }
database/migrations/2023_03_01_073041_create_news_table.php
... ... @@ -15,10 +15,10 @@ return new class extends Migration
15 15 {
16 16 Schema::create('news', function (Blueprint $table) {
17 17 $table->id();
18   - $table->string('slug', 255);
19   - $table->string('title', 255);
20   - $table->text('text');
21   - $table->string('foto', 255);
  18 + //$table->string('slug', 255);
  19 + $table->string('title', 255)->nullable();
  20 + $table->text('text')->nullable();
  21 + $table->string('foto', 255)->nullable();
22 22 $table->timestamps();
23 23 });
24 24 }
database/migrations/2023_03_01_073135_create_contacts_table.php
... ... @@ -29,6 +29,7 @@ return new class extends Migration
29 29 $table->string('title3', 255)->default('');
30 30 $table->text('text3')->nullable(true);
31 31 $table->integer('year')->default(15);
  32 + $table->text('conf')->nullable();
32 33 $table->timestamps();
33 34 });
34 35 }
resources/views/admin/area/add_img.blade.php
... ... @@ -0,0 +1,33 @@
  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.area.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>Название: {{ $area->name_area }} ID: ({{ $area->id }})</h3>
  20 + <form method="post" enctype="multipart/form-data" action="{{ route('admin.img.add.area', ['area' => $area->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 +
  29 +
  30 + </div>
  31 + </div>
  32 + </section>
  33 +@endsection
resources/views/admin/area/edit.blade.php
... ... @@ -19,6 +19,35 @@
19 19 <form method="post" enctype="multipart/form-data" action="{{ route('admin.area.update', ['area' => $area->id]) }}" style="width:100%">
20 20 @include('admin.area.form')
21 21 </form>
  22 + <br><br>
  23 + <h3>Дополнительные картинки</h3>
  24 + <a style="color:green" href="{{ route ('admin.img.area', ['area' => $area->id]) }}">Добавить картинку в галерею</a>
  25 + <table class="table" style="width: 100%">
  26 + <thead>
  27 + <tr>
  28 + <th>ID</th>
  29 + <th>Фото</th>
  30 + <th>Действия</th>
  31 + </tr>
  32 + </thead>
  33 + <tbody>
  34 + @if ($area->fotos->count())
  35 + @foreach($area->fotos as $img)
  36 + <tr>
  37 + <td><?=$img->id?></td>
  38 + <td><img src="<?=asset(Storage::url($img->foto))?>" width="100px"/></td>
  39 + <td><a href="{{ route('admin.img.del.area', ['id'=> $img->id, 'area' => $area->id]) }}">Удалить</a></td>
  40 + </tr>
  41 + @endforeach
  42 + @else
  43 + <tr>
  44 + <td>-</td>
  45 + <td>-</td>
  46 + <td>-</td>
  47 + </tr>
  48 + @endif
  49 + </tbody>
  50 + </table>
22 51 </div>
23 52 </div>
24 53 </section>
resources/views/admin/company/edit.blade.php
... ... @@ -0,0 +1,134 @@
  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"><span class="breadcrumbs__link">Редактирование реквизитов компании </span></li>
  11 + </ul>
  12 + </div>
  13 + <h1 class="favorites__title title-main">Редактирование рекзвизитов компании</h1>
  14 + </div>
  15 + </div>
  16 + <div class="favorites-cnt">
  17 + <div class="container">
  18 + <form method="post" enctype="multipart/form-data" action="{{ route('admin.company.update', ['company' => $firm_data->id])}}" style="width:100%">
  19 + @csrf
  20 +
  21 + @method('PUT')
  22 +
  23 + <label for="email">Почта: </label><br>
  24 + @error('email')
  25 + <div class="alert alert-danger">{{ $message }}</div>
  26 + @enderror
  27 + <input type="text" class="form-control_ txt" name="email" placeholder="Почта"
  28 + required maxlength="100" style="width: 80%" value="{{ old('email') ?? $firm_data->email ?? '' }}"><br>
  29 +
  30 + <label for="telephone">Телефон:</label><br>
  31 + @error('telephone')
  32 + <div class="alert alert-danger">{{ $message }}</div>
  33 + @enderror
  34 + <input type="text" class="form-control_ txt" name="telephone" placeholder="Телефон"
  35 + required maxlength="100" style="width: 80%" value="{{ old('telephone') ?? $firm_data->telephone ?? '' }}"><br>
  36 +
  37 +
  38 + <label for="title">Заголовок: </label><br>
  39 + @error('title')
  40 + <div class="alert alert-danger">{{ $message }}</div>
  41 + @enderror
  42 + <input type="text" class="form-control_ txt" name="title" placeholder="Заголовок"
  43 + required maxlength="100" style="width: 80%" value="{{ old('title') ?? $firm_data->title ?? '' }}"><br>
  44 +
  45 + <label for="title_t">Подзаголовок: </label><br>
  46 + @error('title_t')
  47 + <div class="alert alert-danger">{{ $message }}</div>
  48 + @enderror
  49 + <input type="text" class="form-control_ txt" name="title_t" placeholder="Подзаголовок"
  50 + required maxlength="100" style="width: 80%" value="{{ old('title_t') ?? $firm_data->title_t ?? '' }}"><br>
  51 +
  52 + <label for="description">Описание: </label><br>
  53 + @error('description')
  54 + <div class="alert alert-danger">{{ $message }}</div>
  55 + @enderror
  56 + <textarea class="form-control_ txtarea ckeditor" name="description" placeholder="Описание" required
  57 + rows="10" style="width: 80%">{{ old('description') ?? $firm_data->description ?? '' }}</textarea><br>
  58 +
  59 + <label for="whatapp">WhatApp: </label><br>
  60 + @error('whatapp')
  61 + <div class="alert alert-danger">{{ $message }}</div>
  62 + @enderror
  63 + <input type="text" class="form-control_ txt" name="whatapp" placeholder="Whatapp"
  64 + required maxlength="100" style="width: 80%" value="{{ old('whatapp') ?? $firm_data->whatapp ?? '' }}"><br>
  65 +
  66 + <label for="telegram">Телеграм: </label><br>
  67 + @error('telegram')
  68 + <div class="alert alert-danger">{{ $message }}</div>
  69 + @enderror
  70 + <input type="text" class="form-control_ txt" name="telegram" placeholder="Телеграмм"
  71 + required maxlength="100" style="width: 80%" value="{{ old('telegram') ?? $firm_data->telegram ?? '' }}"><br>
  72 +
  73 + <label for="title1">Заголовок1 (для компании):</label><br>
  74 + @error('title1')
  75 + <div class="alert alert-danger">{{ $message }}</div>
  76 + @enderror
  77 + <input type="text" class="form-control_ txt" name="title1" placeholder="Заголовок 1"
  78 + required maxlength="100" style="width: 80%" value="{{ old('title1') ?? $firm_data->title1 ?? '' }}"><br>
  79 +
  80 + <label for="text1">Описание1 (для компании): </label><br>
  81 + @error('text1')
  82 + <div class="alert alert-danger">{{ $message }}</div>
  83 + @enderror
  84 + <textarea class="form-control_ txtarea ckeditor" name="text1" placeholder="Описание" required
  85 + rows="10" style="width: 80%">{{ old('text1') ?? $firm_data->text1 ?? '' }}</textarea><br>
  86 +
  87 +
  88 + <label for="title2">Заголовок2 (для компании): </label><br>
  89 + @error('title2')
  90 + <div class="alert alert-danger">{{ $message }}</div>
  91 + @enderror
  92 + <input type="text" class="form-control_ txt" name="title2" placeholder="Заголовок"
  93 + required maxlength="100" style="width: 80%" value="{{ old('title2') ?? $firm_data->title2 ?? '' }}"><br>
  94 +
  95 + <label for="text2">Описание2 (для компании): </label><br>
  96 + @error('text2')
  97 + <div class="alert alert-danger">{{ $message }}</div>
  98 + @enderror
  99 + <textarea class="form-control_ txtarea ckeditor" name="text2" placeholder="Описание" required
  100 + rows="10" style="width: 80%">{{ old('text2') ?? $firm_data->text2 ?? '' }}</textarea><br>
  101 +
  102 + <label for="title3">Заголовок3 (для компании):</label><br>
  103 + @error('title3')
  104 + <div class="alert alert-danger">{{ $message }}</div>
  105 + @enderror
  106 + <input type="text" class="form-control_ txt" name="title3" placeholder="Заголовок3"
  107 + required maxlength="100" style="width: 80%" value="{{ old('title3') ?? $firm_data->title3 ?? '' }}"><br>
  108 +
  109 + <label for="text3">Описание3 (для компании):</label><br>
  110 + @error('text3')
  111 + <div class="alert alert-danger">{{ $message }}</div>
  112 + @enderror
  113 + <textarea class="form-control_ txtarea ckeditor" name="text3" placeholder="Описание" required
  114 + rows="10" style="width: 80%">{{ old('text3') ?? $firm_data->text3 ?? '' }}</textarea><br>
  115 +
  116 + <label for="year">Число лет на рынке (для компании): </label><br>
  117 + @error('year')
  118 + <div class="alert alert-danger">{{ $message }}</div>
  119 + @enderror
  120 + <input type="text" class="form-control_ txt" name="year" placeholder="Число лет на рынке"
  121 + required maxlength="100" style="width: 80%" value="{{ old('year') ?? $firm_data->year ?? '' }}"><br>
  122 +
  123 + <label for="conf">Условие: <b>{{$firm_data->conf}}</b></label><br>
  124 + @error('conf')
  125 + <div class="alert alert-danger">{{ $message }}</div>
  126 + @enderror
  127 + <textarea class="form-control_ txtarea ckeditor" name="conf" placeholder="Соглашение" required
  128 + rows="10" style="width: 80%">{{ old('conf') ?? $firm_data->conf ?? '' }}</textarea><br><br>
  129 + <button type="submit" class="btn hero-search__btn btn--main">Сохранить</button>
  130 + </form>
  131 + </div>
  132 + </div>
  133 + </section>
  134 +@endsection
resources/views/admin/company/view.blade.php
... ... @@ -0,0 +1,60 @@
  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"><span class="breadcrumbs__link">Настройки компании </span></li>
  11 + </ul>
  12 + </div>
  13 + <h1 class="favorites__title title-main">Настройки компании</h1>
  14 + </div>
  15 + </div>
  16 + <div class="favorites-cnt">
  17 + <div class="container">
  18 + <a href="{{ route('admin.company.edit', ['company' => 1]) }}" class="btn hero-search__btn btn--main">
  19 + Редактировать реквизиты компании
  20 + </a><br><br>
  21 +
  22 + <label for="email">Почта: <b>{{$firm_data->email}}</b></label><br><br>
  23 +
  24 + <label for="telephone">Телефон: <b>{{$firm_data->telephone}}</b></label><br><br>
  25 +
  26 + <label for="title">Заголовок: <b>{{$firm_data->title}}</b></label><br><br>
  27 +
  28 + <label for="title">Подзаголовок: <b>{{$firm_data->title_t}}</b></label><br><br>
  29 +
  30 + <label for="title">Описание: <b>{{$firm_data->description}}</b></label><br><br>
  31 +
  32 + <label for="title">WhatApp: <b>{{$firm_data->whatapp}}</b></label><br><br>
  33 +
  34 + <label for="title">Телеграм: <b>{{$firm_data->telegram}}</b></label><br><br>
  35 +
  36 + <label for="title">Заголовок1 (для компании): <b>{{$firm_data->title1}}</b></label><br><br>
  37 +
  38 + <label for="title">Описание1 (для компании): <b>{{$firm_data->text1}}</b></label><br><br>
  39 +
  40 + <label for="title">Заголовок2 (для компании): <b>{{$firm_data->title2}}</b></label><br><br>
  41 +
  42 + <label for="title">Описание2 (для компании): <b>{{$firm_data->text2}}</b></label><br><br>
  43 +
  44 + <label for="title">Заголовок3 (для компании): <b>{{$firm_data->title3}}</b></label><br><br>
  45 +
  46 + <label for="title">Описание3 (для компании): <b>{{$firm_data->text3}}</b></label><br><br>
  47 +
  48 + <label for="title">Число лет на рынке (для компании): <b>{{$firm_data->year}}</b></label><br><br>
  49 +
  50 + <label for="title">Условие: <b>{{$firm_data->conf}}</b></label><br><br>
  51 +
  52 +
  53 +
  54 +
  55 +
  56 +
  57 + </div>
  58 + </div>
  59 + </section>
  60 +@endsection
resources/views/admin/news/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.news.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.news.store') }}" style="width:100%">
  20 + @include('admin.news.form')
  21 + </form>
  22 + </div>
  23 + </div>
  24 + </section>
  25 +@endsection
resources/views/admin/news/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.news.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.news.update', ['news' => $news->id])}}" style="width:100%">
  20 + @include('admin.news.form')
  21 + </form>
  22 + </div>
  23 + </div>
  24 + </section>
  25 +@endsection
resources/views/admin/news/form.blade.php
... ... @@ -0,0 +1,34 @@
  1 +@csrf
  2 +
  3 +@isset($news)
  4 + @method('PUT')
  5 +@endisset
  6 +
  7 +<label for="name_area">Заголовок новости: <span class="req">*</span></label>
  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') ?? $news->title ?? '' }}"><br>
  13 +
  14 +<label for="text">Текст новости: <span class="req">*</span></label>
  15 +@error('text')
  16 +<div class="alert alert-danger">{{ $message }}</div>
  17 +@enderror
  18 +<textarea class="form-control_ txtarea ckeditor" name="text" placeholder="Текст новости" required
  19 + rows="10" style="width: 80%">{{ old('text') ?? $news->text ?? '' }}</textarea><br>
  20 +
  21 +<label for="foto">Файл-картинка:</label>
  22 +<input type="file" class="form-control-file txt" name="foto" id="foto" accept="image/png, image/jpeg">
  23 +
  24 +@isset($news->foto)
  25 + <div class="form-group form-check">
  26 + <img src="<?=asset(Storage::url($news->foto))?>" width="100px"/>
  27 + <input type="checkbox" class="form-check-input" name="remove" id="remove">
  28 + <label class="form-check-label" for="remove">
  29 + Удалить загруженное изображение
  30 + </label>
  31 + </div>
  32 +@endisset
  33 +<br><br>
  34 +<button type="submit" class="btn hero-search__btn btn--main">Сохранить</button>
resources/views/admin/news/index.blade.php
... ... @@ -0,0 +1,86 @@
  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"><span class="breadcrumbs__link">Новости </span></li>
  11 + </ul>
  12 + </div>
  13 + <h1 class="favorites__title title-main">Новости</h1>
  14 + </div>
  15 + </div>
  16 + <div class="favorites-cnt">
  17 + <div class="container">
  18 + <a href="{{ route('admin.news.create') }}" class="btn hero-search__btn btn--main">
  19 + Создать новость
  20 + </a><br><br>
  21 + <table class="table" style="width: 100%">
  22 + <thead>
  23 + <tr>
  24 + <th>Фото</th>
  25 + <th>ID</th>
  26 + <th>Название новости</th>
  27 + <th>Дата создания</th>
  28 + <th>Действия</th>
  29 + </tr>
  30 + </thead>
  31 + <tbody>
  32 + @if ($news->count())
  33 + @foreach($news as $new)
  34 + <tr>
  35 + <td><? if (empty($new->foto)) {?>Нет фото<?} else {?><img src="<?=asset(Storage::url($new->foto))?>" width="100px"/><?}?></td>
  36 + <td>{{ $new->id }}</td>
  37 + <td>{{ $new->title }}</td>
  38 + <td>{{ $new->created_at }}</td>
  39 + <td> <form action="{{ route('admin.news.destroy', $new) }}" method="POST">
  40 + <a style="color:green" href="{{ route('admin.news.show', ['news' => $new->id]) }}">
  41 + Просмотр
  42 + </a> |
  43 + <a href="{{ route('admin.news.edit', ['news' => $new->id]) }}">
  44 + Редактировать
  45 + </a> |
  46 + @csrf
  47 + @method('DELETE')
  48 + <input class=" btn-danger" type="submit" value="Удалить">
  49 + </form>
  50 + </td>
  51 + </tr>
  52 + @endforeach
  53 + @else
  54 + <tr>
  55 + <td>-</td>
  56 + <td>-</td>
  57 + <td>-</td>
  58 + <td>-</td>
  59 + <td>-</td>
  60 + </tr>
  61 + @endif
  62 +
  63 + </tbody>
  64 + </table>
  65 + {{ $news->onEachSide(1)->links('catalogs.paginate') }}
  66 + <div class="favorites__items">
  67 +
  68 +
  69 +
  70 + <!--<div class="favorites-item">
  71 + <div class="favorites-item__img"><img src="images/favorites/favorites-item-img-1.svg" alt=""></div>
  72 + <p class="favorites-item__descr"><a href="#">Найдите</a> идеальную планировку на сайте Renttorg</p>
  73 + </div>
  74 + <div class="favorites-item">
  75 + <div class="favorites-item__img"><img src="images/favorites/favorites-item-img-2.svg" alt=""></div>
  76 + <p class="favorites-item__descr">Нажмите на <img src="images/favorites-icon-mini.svg" alt=""> для добавления недвижемости в избранное</p>
  77 + </div>
  78 + <div class="favorites-item">
  79 + <div class="favorites-item__img"><img src="images/favorites/favorites-item-img-3.svg" alt=""></div>
  80 + <p class="favorites-item__descr">Перейдите в избранное или сравнение для выбора планировки</p>
  81 + </div>-->
  82 + </div>
  83 + </div>
  84 + </div>
  85 + </section>
  86 +@endsection
resources/views/admin/news/view.blade.php
... ... @@ -0,0 +1,38 @@
  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.news.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 + <label for="name_area">Заголовок новости: <span class="req">*</span></label>
  20 + <input type="text" class="form-control_ txt" name="title" placeholder="Заголовок новости"
  21 + required maxlength="100" style="width: 80%" value="{{ old('title') ?? $news->title ?? '' }}"><br>
  22 +
  23 + <label for="text">Текст новости: <span class="req">*</span></label>
  24 + <textarea class="form-control_ txtarea ckeditor" name="text" placeholder="Текст новости" required
  25 + rows="10" style="width: 80%">{{ old('text') ?? $news->text ?? '' }}</textarea><br>
  26 +
  27 + <label for="foto">Файл-картинка:</label>
  28 + @isset($news->foto)
  29 + <div class="form-group form-check">
  30 + <img src="<?=asset(Storage::url($news->foto))?>" width="100px"/>
  31 + </div>
  32 + @endisset
  33 + <br><br>
  34 + <a href="{{ route('admin.news.index') }}" class="btn hero-search__btn btn--main">Вернуться к новостям</a>
  35 + </div>
  36 + </div>
  37 + </section>
  38 +@endsection
resources/views/layout/admin.blade.php
... ... @@ -84,8 +84,8 @@
84 84 <nav class="header__nav nav">
85 85 <ul class="nav__list">
86 86 <li class="nav__item"><a class="nav__link" href="{{ route('admin.area.index') }}">Объекты</a></li>
87   - <li class="nav__item"><a class="nav__link" href="{{ route('about') }}">О компании</a></li>
88   - <li class="nav__item"><a class="nav__link" href="{{ route('contact') }}">Контакты</a></li>
  87 + <li class="nav__item"><a class="nav__link" href="{{ route('admin.news.index') }}">Новости</a></li>
  88 + <li class="nav__item"><a class="nav__link" href="{{ route('admin.company.show', ['company' => 1]) }}">Компания</a></li>
89 89 <li class="nav__item"><a class="nav__link nav__link-favorites" href="{{ route('favorite') }}">Избранное<span><?=\App\Classes\RusDate::count_item_fav();?></span></a></li>
90 90 </ul>
91 91 </nav>
... ... @@ -109,9 +109,9 @@
109 109 <div class="menu__inner">
110 110 <nav class="menu__nav">
111 111 <ul class="menu__list">
112   - <li class="menu__item"><a class="menu__link" href="{{ route('about') }}">О компании</a></li>
113   - <li class="menu__item"><a class="menu__link menu__link-favorites" href="{{ route('favorite') }}">Избранное<span>5</span></a></li>
114   - <li class="menu__item"><a class="menu__link" href="{{ route('catalog') }}">Каталог</a></li>
  112 + <li class="menu__item"><a class="menu__link" href="{{ route('admin.area.index') }}">Объекты</a></li>
  113 + <li class="menu__item"><a class="menu__link" href="{{ route('admin.news.index') }}">Новости</a></li>
  114 + <li class="menu__item"><a class="menu__link" href="{{ route('admin.company.show', ['company' => 1]) }}">Компания</a></li>
115 115 <li class="menu__item"><a class="menu__link" href="{{ route('news') }}">Новости</a></li>
116 116 <li class="menu__item"><a class="menu__link" href="{{ route('contact') }}">Контакты</a></li>
117 117 </ul>
... ... @@ -7,6 +7,12 @@ use App\Http\Controllers\RegisterController;
7 7 use App\Http\Controllers\LoginController;
8 8 use App\Http\Controllers\AdminController;
9 9 use App\Http\Controllers\Admin\AreaController;
  10 +use App\Http\Controllers\Admin\NewsController;
  11 +use App\Http\Controllers\Admin\CompanyAreaController;
  12 +use App\Http\Controllers\Admin\FormatAreaController;
  13 +use App\Http\Controllers\Admin\TypeAreaController;
  14 +use App\Http\Controllers\Admin\HousesController;
  15 +use App\Http\Controllers\Admin\MessageAreaController;
10 16  
11 17 /*
12 18 |--------------------------------------------------------------------------
... ... @@ -135,7 +141,26 @@ Route::group([
135 141 */
136 142 Route::resource('area', AreaController::class, []);
137 143  
138   - //дополнительный маршрут для показа постов с жилыми массивами
139   - Route::get('post/area/{area}', [AreaController::class, 'area_category'])
140   - ->name('post.area');
  144 + //дополнительный маршрут для показа картинок объектов недвижимости
  145 + Route::get('img/area/{area}', [AreaController::class, 'area_category'])
  146 + ->name('img.area');
  147 +
  148 + //дополнительный маршрут для добавления картинок объектов недвижимости
  149 + Route::post('img/area/{area}', [AreaController::class, 'area_add_img'])
  150 + ->name('img.add.area');
  151 +
  152 + //дополнительный маршрут для удаления картинок объектов недвжимости
  153 + Route::get('img/del/{id}/area/{area}', [AreaController::class, 'area_del_img'])
  154 + ->name('img.del.area');
  155 +
  156 + /*
  157 + * CRUD-операции над постами Новости
  158 + */
  159 + Route::resource('news', NewsController::class, []);
  160 +
  161 + /*
  162 + * CRUD-операции над настройками Компании
  163 + */
  164 + Route::resource('company', CompanyAreaController::class, ['except' => ['create', 'store', 'destroy', 'index']]);
  165 +
141 166 });