From b349420bec7e3003e305f5da2edb63bc6996efbe Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 24 Jul 2020 13:11:21 +0200 Subject: [PATCH] :sparkles: Ajoute les liens publics --- app/Http/Controllers/PublicController.php | 14 ++++ ...4_102725_update_homes_with_public_uuid.php | 32 +++++++++ resources/views/homes/add.blade.php | 10 +++ resources/views/homes/update.blade.php | 10 +++ resources/views/homes/view.blade.php | 3 +- resources/views/public/view.blade.php | 72 +++++++++++++++++++ routes/web.php | 16 +++-- 7 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 app/Http/Controllers/PublicController.php create mode 100644 database/migrations/2020_07_24_102725_update_homes_with_public_uuid.php create mode 100644 resources/views/public/view.blade.php diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php new file mode 100644 index 0000000..9919619 --- /dev/null +++ b/app/Http/Controllers/PublicController.php @@ -0,0 +1,14 @@ +firstOrFail(); + return view('public.view', ['home' => $home]); + } +} diff --git a/database/migrations/2020_07_24_102725_update_homes_with_public_uuid.php b/database/migrations/2020_07_24_102725_update_homes_with_public_uuid.php new file mode 100644 index 0000000..3dfdfc9 --- /dev/null +++ b/database/migrations/2020_07_24_102725_update_homes_with_public_uuid.php @@ -0,0 +1,32 @@ +string('slug')->nullable()->comment('Uuid for public link'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('homes', static function (Blueprint $table) { + $table->dropColumn('slug'); + }); + } +} diff --git a/resources/views/homes/add.blade.php b/resources/views/homes/add.blade.php index 73ea5b0..3d1fa80 100644 --- a/resources/views/homes/add.blade.php +++ b/resources/views/homes/add.blade.php @@ -96,6 +96,16 @@ +
+
+ + +
+
+ + +
+
diff --git a/resources/views/homes/update.blade.php b/resources/views/homes/update.blade.php index 8995863..b9be968 100644 --- a/resources/views/homes/update.blade.php +++ b/resources/views/homes/update.blade.php @@ -99,6 +99,16 @@ +
+
+ slug)) checked @endif> + +
+
+ slug)) checked @endif value="@if(!empty($home->slug)) {{ $home->slug }} @else {{ \Illuminate\Support\Str::uuid() }} @endif"> + +
+
diff --git a/resources/views/homes/view.blade.php b/resources/views/homes/view.blade.php index e9e3a2b..006b0a0 100644 --- a/resources/views/homes/view.blade.php +++ b/resources/views/homes/view.blade.php @@ -67,7 +67,8 @@
GES : {{ $home->ges ?? '−' }}
- + @if(!empty($home->slug)) @endif +
diff --git a/resources/views/public/view.blade.php b/resources/views/public/view.blade.php new file mode 100644 index 0000000..7e55720 --- /dev/null +++ b/resources/views/public/view.blade.php @@ -0,0 +1,72 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+ + +
+ +
+
+ +
+
+ @if(!empty($home->comment)) +
+
Mon commentaire
+
+ {!! nl2br($home->comment) !!} +
+
+ @endif +
+
+ {!! nl2br($home->description) !!} +
+
+
+

Informations :

+
Ville : {{ $home->city }}
+
Prix : {{ $home->price }}
+
Surface : {{ $home->surface }} m²
+
Nombre de pièces : {{ $home->rooms }}
+
+
+

Informations complémentaires :

+
Surface de jardin : {{ $home->garden_surface ?? '−' }}
+
Énergie : {{ $home->energy ?? '−' }}
+
GES : {{ $home->ges ?? '−' }}
+
+ +
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index e68c148..d446894 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ name('public.view'); + Route::group(['middleware' => ['auth']], static function () { Route::get('/home', 'HomeController@index')->name('home');