diff --git a/app/Http/Controllers/Admin/CompanyAreaController.php b/app/Http/Controllers/Admin/CompanyAreaController.php index 6a13b01..3cdf2d5 100644 --- a/app/Http/Controllers/Admin/CompanyAreaController.php +++ b/app/Http/Controllers/Admin/CompanyAreaController.php @@ -4,7 +4,10 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Contact; +use App\Models\Partners; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Session; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; class CompanyAreaController extends Controller @@ -49,7 +52,8 @@ class CompanyAreaController extends Controller public function show(Contact $contact) { $firm_data = Contact::find(1); - return view('admin.company.view', compact('firm_data')); + $partners = Partners::query()->get(); + return view('admin.company.view', compact('firm_data', 'partners')); } /** @@ -104,4 +108,50 @@ class CompanyAreaController extends Controller { // } + + /** + * Добавление партнера + */ + public function add_partner() { + return view('admin.company.add_partner'); + } + + /** + * Сохранение нового партнера + */ + public function add_partner_post(Request $request) { + $rules = [ + 'name' => 'required|min:3|max:255', + 'foto' => 'required|min:3|max:255', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.add.partner') + ->withErrors($validator); + } else { + //$params = $request->all(); + $partner = new Partners(); + $partner->name = $request->name; + $partner->foto = $request->file('foto')->store('partners', 'public'); + $partner->save(); + + return redirect()->route('admin.company.show', ['company' => 1]); + } + } + + /** + * Удаление партнера + */ + public function delete_partner(Partners $partner) { + Storage::delete($partner->foto); + $partner->delete(); + Session::flash('message','Партнер был успешно удален!'); + + return redirect()->route('admin.company.show', ['company' => 1]); + } } diff --git a/app/Http/Controllers/Admin/FormatAreaController.php b/app/Http/Controllers/Admin/FormatAreaController.php index 39c3d67..293861d 100644 --- a/app/Http/Controllers/Admin/FormatAreaController.php +++ b/app/Http/Controllers/Admin/FormatAreaController.php @@ -4,7 +4,9 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\format_area; +use App\Models\type_area; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; class FormatAreaController extends Controller { @@ -15,7 +17,9 @@ class FormatAreaController extends Controller */ public function index() { - // + $formatareas = format_area::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(5); + return view('admin.formatarea.index', compact('formatareas')); + } /** @@ -25,7 +29,7 @@ class FormatAreaController extends Controller */ public function create() { - // + return view('admin.formatarea.create'); } /** @@ -36,7 +40,23 @@ class FormatAreaController extends Controller */ public function store(Request $request) { - // + $rules = [ + 'name_format' => 'required|min:3|max:255', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.formatarea.create') + ->withErrors($validator); + } else { + $params = $request->all(); + format_area::create($params); + return redirect()->route('admin.formatarea.index'); + } } /** @@ -53,34 +73,51 @@ class FormatAreaController extends Controller /** * Show the form for editing the specified resource. * - * @param \App\Models\format_area $format_area + * @param \App\Models\format_area $formatarea * @return \Illuminate\Http\Response */ - public function edit(format_area $format_area) + public function edit(format_area $formatarea) { - // + return view('admin.formatarea.edit', compact('formatarea')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request - * @param \App\Models\format_area $format_area + * @param \App\Models\format_area $formatarea * @return \Illuminate\Http\Response */ - public function update(Request $request, format_area $format_area) + public function update(Request $request, format_area $formatarea) { - // + $rules = [ + 'name_format' => 'required|min:3|max:255', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.formatarea.edit') + ->withErrors($validator); + } else { + $params = $request->all(); + $formatarea->update($params); + return redirect()->route('admin.formatarea.index'); + } } /** * Remove the specified resource from storage. * - * @param \App\Models\format_area $format_area + * @param \App\Models\format_area $formatarea * @return \Illuminate\Http\Response */ - public function destroy(format_area $format_area) + public function destroy(format_area $formatarea) { - // + $formatarea->delete(); + return redirect()->route('admin.formatarea.index'); } } diff --git a/app/Http/Controllers/Admin/HousesController.php b/app/Http/Controllers/Admin/HousesController.php index 7d4fe66..675b41b 100644 --- a/app/Http/Controllers/Admin/HousesController.php +++ b/app/Http/Controllers/Admin/HousesController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Http\Requests\HousesRequest; use App\Models\House; use Illuminate\Http\Request; @@ -15,7 +16,9 @@ class HousesController extends Controller */ public function index() { - // + $houses = House::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(25); + return view('admin.houses.index', compact('houses')); + } /** @@ -25,7 +28,7 @@ class HousesController extends Controller */ public function create() { - // + return view('admin.houses.create'); } /** @@ -34,9 +37,24 @@ class HousesController extends Controller * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(HousesRequest $request) { - // + $params = $request->all(); + //unset($params['foto_main']); + + if ($request->has('foto_main')) { + $params['foto_main'] = $request->file('foto_main')->store('houses', 'public'); + } + if ($request->has('object_plan')) { + $params['object_plan'] = $request->file('object_plan')->store('houses', 'public'); + } + if ($request->has('floor_plan')) { + $params['floor_plan'] = $request->file('floor_plan')->store('houses', 'public'); + } + + + House::create($params); + return redirect()->route('admin.houses.index'); } /** diff --git a/app/Http/Controllers/Admin/MessageAreaController.php b/app/Http/Controllers/Admin/MessageAreaController.php index dbfb0be..3552253 100644 --- a/app/Http/Controllers/Admin/MessageAreaController.php +++ b/app/Http/Controllers/Admin/MessageAreaController.php @@ -15,7 +15,9 @@ class MessageAreaController extends Controller */ public function index() { - // + $messages = ModelMailFeedback::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(20); + return view('admin.messages.index', compact('messages')); + } /** @@ -42,12 +44,12 @@ class MessageAreaController extends Controller /** * Display the specified resource. * - * @param \App\Models\ModelMailFeedback $modelMailFeedback + * @param \App\Models\ModelMailFeedback $message * @return \Illuminate\Http\Response */ - public function show(ModelMailFeedback $modelMailFeedback) + public function show(ModelMailFeedback $message) { - // + return view('admin.messages.view', compact('message')); } /** @@ -76,11 +78,12 @@ class MessageAreaController extends Controller /** * Remove the specified resource from storage. * - * @param \App\Models\ModelMailFeedback $modelMailFeedback + * @param \App\Models\ModelMailFeedback $message * @return \Illuminate\Http\Response */ - public function destroy(ModelMailFeedback $modelMailFeedback) + public function destroy(ModelMailFeedback $message) { - // + $message->delete(); + return redirect()->route('admin.message.index'); } } diff --git a/app/Http/Controllers/Admin/TypeAreaController.php b/app/Http/Controllers/Admin/TypeAreaController.php index 099b339..6a6d124 100644 --- a/app/Http/Controllers/Admin/TypeAreaController.php +++ b/app/Http/Controllers/Admin/TypeAreaController.php @@ -4,7 +4,10 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\type_area; +use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Validator; class TypeAreaController extends Controller { @@ -15,7 +18,8 @@ class TypeAreaController extends Controller */ public function index() { - // + $typeareas = type_area::query()->orderByDesc('created_at')->orderByDesc('id')->paginate(5); + return view('admin.typearea.index', compact('typeareas')); } /** @@ -25,7 +29,7 @@ class TypeAreaController extends Controller */ public function create() { - // + return view('admin.typearea.create'); } /** @@ -36,7 +40,23 @@ class TypeAreaController extends Controller */ public function store(Request $request) { - // + $rules = [ + 'name_type' => 'required|min:3|max:255', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.typearea.create') + ->withErrors($validator); + } else { + $params = $request->all(); + type_area::create($params); + return redirect()->route('admin.typearea.index'); + } } /** @@ -53,12 +73,12 @@ class TypeAreaController extends Controller /** * Show the form for editing the specified resource. * - * @param \App\Models\type_area $type_area + * @param \App\Models\type_area $typearea * @return \Illuminate\Http\Response */ - public function edit(type_area $type_area) + public function edit(type_area $typearea) { - // + return view('admin.typearea.edit', compact('typearea')); } /** @@ -68,19 +88,36 @@ class TypeAreaController extends Controller * @param \App\Models\type_area $type_area * @return \Illuminate\Http\Response */ - public function update(Request $request, type_area $type_area) + public function update(Request $request, type_area $typearea) { - // + $rules = [ + 'name_type' => 'required|min:3|max:255', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.typearea.edit') + ->withErrors($validator); + } else { + $params = $request->all(); + $typearea->update($params); + return redirect()->route('admin.typearea.index'); + } } /** * Remove the specified resource from storage. * - * @param \App\Models\type_area $type_area + * @param \App\Models\type_area $typearea * @return \Illuminate\Http\Response */ - public function destroy(type_area $type_area) + public function destroy(type_area $typearea) { - // + $typearea->delete(); + return redirect()->route('admin.typearea.index'); } } diff --git a/app/Http/Requests/HousesRequest.php b/app/Http/Requests/HousesRequest.php new file mode 100644 index 0000000..6f2e897 --- /dev/null +++ b/app/Http/Requests/HousesRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules() + { + return [ + // + ]; + } +} diff --git a/app/Models/format_area.php b/app/Models/format_area.php index 90d2562..cbc6e27 100644 --- a/app/Models/format_area.php +++ b/app/Models/format_area.php @@ -11,6 +11,8 @@ class format_area extends Model protected $table = 'format_area'; + protected $fillable = ['name_format']; + /* * Связь справочника-таблицы ФОРМАТ НЕДВИЖИМОСТИ с таблицей ОФИСЫ */ diff --git a/app/Models/type_area.php b/app/Models/type_area.php index a44a8f9..4dd3cc1 100644 --- a/app/Models/type_area.php +++ b/app/Models/type_area.php @@ -11,6 +11,9 @@ class type_area extends Model protected $table = 'type_area'; + protected $fillable = ['name_type']; + + /* * Связь таблицы ТИП НЕДВИЖИМОСТИ с таблицей ОФИСЫ */ diff --git a/resources/views/admin/company/add_partner.blade.php b/resources/views/admin/company/add_partner.blade.php new file mode 100644 index 0000000..e0e086b --- /dev/null +++ b/resources/views/admin/company/add_partner.blade.php @@ -0,0 +1,37 @@ +@extends('layout.admin', ['title' => 'Добавление партнера компании']) + +@section('content') +
+
+
+ +

Добавление партнера компании

+
+
+
+
+
+ @csrf + +
+ @error('name') +
{{ $message }}
+ @enderror +
+ + +

+ + +
+
+
+
+@endsection diff --git a/resources/views/admin/company/view.blade.php b/resources/views/admin/company/view.blade.php index a9f4911..08aa86f 100644 --- a/resources/views/admin/company/view.blade.php +++ b/resources/views/admin/company/view.blade.php @@ -48,13 +48,33 @@



- - - - - - + @if ($partners->count()) +
+
+

Партнеры нашей компании

+ + + Добавить партнера +
+
+
+
+
+ @foreach ($partners as $partner) + + @endforeach + +
+
+
+
+
+
+


+ @endif @endsection diff --git a/resources/views/admin/formatarea/create.blade.php b/resources/views/admin/formatarea/create.blade.php new file mode 100644 index 0000000..7bdca60 --- /dev/null +++ b/resources/views/admin/formatarea/create.blade.php @@ -0,0 +1,25 @@ +@extends('layout.admin', ['title' => 'Создание формата недвижимости']) + +@section('content') +
+
+
+ +

Создание формата недвижимости

+
+
+
+
+
+ @include('admin.formatarea.form') +
+
+
+
+@endsection diff --git a/resources/views/admin/formatarea/edit.blade.php b/resources/views/admin/formatarea/edit.blade.php new file mode 100644 index 0000000..d754d39 --- /dev/null +++ b/resources/views/admin/formatarea/edit.blade.php @@ -0,0 +1,25 @@ +@extends('layout.admin', ['title' => 'Редактирование формата недвижимости']) + +@section('content') +
+
+
+ +

Редактирование формата недвижимости

+
+
+
+
+
+ @include('admin.formatarea.form') +
+
+
+
+@endsection diff --git a/resources/views/admin/formatarea/form.blade.php b/resources/views/admin/formatarea/form.blade.php new file mode 100644 index 0000000..f646659 --- /dev/null +++ b/resources/views/admin/formatarea/form.blade.php @@ -0,0 +1,16 @@ +@csrf + +@isset($formatarea) + @method('PUT') +@endisset + + +@error('name_format') +
{{ $message }}
+@enderror +
+
+ +
+ diff --git a/resources/views/admin/formatarea/index.blade.php b/resources/views/admin/formatarea/index.blade.php new file mode 100644 index 0000000..2788ace --- /dev/null +++ b/resources/views/admin/formatarea/index.blade.php @@ -0,0 +1,67 @@ +@extends('layout.admin', ['title' => 'Форматы недвижимости']) + +@section('content') +
+
+
+ +

Форматы недвижимости

+
+
+
+
+ + Создать формат +

+ + + + + + + + + + + @if ($formatareas->count()) + @foreach($formatareas as $formatarea) + + + + + + + @endforeach + @else + + + + + + + + @endif + + +
IDНазвание форматаДата созданияДействия
{{ $formatarea->id }}{{ $formatarea->name_format }}{{ $formatarea->created_at }}
+ + Редактировать + | + @csrf + @method('DELETE') + +
+
-----
+ {{ $formatareas->onEachSide(1)->links('catalogs.paginate') }} +
+ +
+
+
+
+@endsection diff --git a/resources/views/admin/houses/create.blade.php b/resources/views/admin/houses/create.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/admin/houses/edit.blade.php b/resources/views/admin/houses/edit.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/admin/houses/form.blade.php b/resources/views/admin/houses/form.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/admin/houses/index.blade.php b/resources/views/admin/houses/index.blade.php new file mode 100644 index 0000000..929d119 --- /dev/null +++ b/resources/views/admin/houses/index.blade.php @@ -0,0 +1,78 @@ +@extends('layout.admin', ['title' => 'Офисы']) + +@section('content') +
+
+
+ +

Офисы

+
+
+
+
+ + Создать офис +

+ + + + + + + + + + + + + + @if ($houses->count()) + @foreach($houses as $house) + + + + + + + + + + @endforeach + @else + + + + + + + + + + @endif + + +
ФотоIDНазвание офисаЖилой комплексАдресДата созданияДействия
foto_main)) {?>Нет фото{{ $house->id }}{{ $house->title }}{{ $house->areas->name_area }}{{ $house->address }}{{ $house->created_at }}
+ + Просмотр + | + + Редактировать + | + @csrf + @method('DELETE') + +
+
-------
+ {{ $houses->onEachSide(1)->links('catalogs.paginate') }} +
+ +
+
+
+
+@endsection diff --git a/resources/views/admin/messages/index.blade.php b/resources/views/admin/messages/index.blade.php new file mode 100644 index 0000000..6527602 --- /dev/null +++ b/resources/views/admin/messages/index.blade.php @@ -0,0 +1,64 @@ +@extends('layout.admin', ['title' => 'Сообщения сайту']) + +@section('content') +
+
+
+ +

Сообщения сайту

+
+
+
+
+ + + + + + + + + + + + @if ($messages->count()) + @foreach($messages as $msg) + + + + + + + + @endforeach + @else + + + + + + + + @endif + + +
IDОтТемаДатаДействия
{{ $msg->id }}{{ $msg->from }}{{ $msg->subject }}{{ $msg->created_at }}
+ Просмотр | + @csrf + @method('DELETE') + +
+
-----
+ {{ $messages->onEachSide(1)->links('catalogs.paginate') }} +
+ +
+
+
+
+@endsection diff --git a/resources/views/admin/messages/view.blade.php b/resources/views/admin/messages/view.blade.php new file mode 100644 index 0000000..ef27960 --- /dev/null +++ b/resources/views/admin/messages/view.blade.php @@ -0,0 +1,36 @@ +@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 index e8c398e..2eead11 100644 --- a/resources/views/admin/news/edit.blade.php +++ b/resources/views/admin/news/edit.blade.php @@ -1,4 +1,4 @@ -@extends('layout.admin', ['title' => 'Создание новости']) +@extends('layout.admin', ['title' => 'Редактирование новости']) @section('content')
diff --git a/resources/views/admin/typearea/create.blade.php b/resources/views/admin/typearea/create.blade.php new file mode 100644 index 0000000..2d1db7c --- /dev/null +++ b/resources/views/admin/typearea/create.blade.php @@ -0,0 +1,25 @@ +@extends('layout.admin', ['title' => 'Создание типа недвижимости']) + +@section('content') +
+
+
+ +

Создание типа недвижимости

+
+
+
+
+
+ @include('admin.typearea.form') +
+
+
+
+@endsection diff --git a/resources/views/admin/typearea/edit.blade.php b/resources/views/admin/typearea/edit.blade.php new file mode 100644 index 0000000..47f1d53 --- /dev/null +++ b/resources/views/admin/typearea/edit.blade.php @@ -0,0 +1,25 @@ +@extends('layout.admin', ['title' => 'Редактирование типа недвижимости']) + +@section('content') +
+
+
+ +

Редактирование типа недвижимости

+
+
+
+
+
+ @include('admin.typearea.form') +
+
+
+
+@endsection diff --git a/resources/views/admin/typearea/form.blade.php b/resources/views/admin/typearea/form.blade.php new file mode 100644 index 0000000..0a8d93a --- /dev/null +++ b/resources/views/admin/typearea/form.blade.php @@ -0,0 +1,16 @@ +@csrf + +@isset($typearea) + @method('PUT') +@endisset + + +@error('name_type') +
{{ $message }}
+@enderror +
+
+ +
+ diff --git a/resources/views/admin/typearea/index.blade.php b/resources/views/admin/typearea/index.blade.php new file mode 100644 index 0000000..9beb12e --- /dev/null +++ b/resources/views/admin/typearea/index.blade.php @@ -0,0 +1,67 @@ +@extends('layout.admin', ['title' => 'Типы недвижимости']) + +@section('content') +
+
+
+ +

Типы недвижимости

+
+
+
+
+ + Создать тип +

+ + + + + + + + + + + @if ($typeareas->count()) + @foreach($typeareas as $typearea) + + + + + + + @endforeach + @else + + + + + + + + @endif + + +
IDНазвание типаДата созданияДействия
{{ $typearea->id }}{{ $typearea->name_type }}{{ $typearea->created_at }}
+ + Редактировать + | + @csrf + @method('DELETE') + +
+
-----
+ {{ $typeareas->onEachSide(1)->links('catalogs.paginate') }} +
+ +
+
+
+
+@endsection diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 8cfa845..d143036 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -86,7 +86,11 @@ - + + + + +
@@ -112,8 +116,10 @@ - - + + + + diff --git a/routes/web.php b/routes/web.php index 437dafe..d178e8b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -163,4 +163,34 @@ Route::group([ */ Route::resource('company', CompanyAreaController::class, ['except' => ['create', 'store', 'destroy', 'index']]); + //форма добавление партнера + Route::get('add/partner', [CompanyAreaController::class, 'add_partner'])->name('add.partner'); + + //Добавление партнера + Route::post('add/partner', [CompanyAreaController::class, 'add_partner_post'])->name('add.partner.post'); + + //удаление партнера + Route::get('delete/partner/{partner}', [CompanyAreaController::class, 'delete_partner'])->name('delete.partner'); + + + /* + * CRUD-операции над типами недвижимостью + */ + Route::resource('typearea', TypeAreaController::class, ['except' => ['show']]); + + /* + * CRUD-операции над форматами недвижимостью + */ + Route::resource('formatarea', FormatAreaController::class, ['except' => ['show']]); + + /* + * CRUD-операции над сообщениями сайта + */ + Route::resource('message', MessageAreaController::class, ['except' => ['create', 'store', 'edit', 'update']]); + + /* + * CRUD-операции над офисами + */ + Route::resource('houses', HousesController::class, ['except' => ['show']]); + });