From b54b9959cfa3379750127cff9fe22073fa90162a Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Tue, 17 Mar 2020 10:57:23 +0100 Subject: [PATCH] :sparkles: Ajoute le moteur de recherche simple Fix #11 --- app/Http/Controllers/DashboardController.php | 6 +++++- app/User.php | 8 ++++++++ resources/views/layouts/connected.blade.php | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 66fc05e..779415b 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -44,7 +44,11 @@ class DashboardController extends Controller $image_counts = Post::where('user_id', Auth::user()->getAuthIdentifier()) ->where('image', '!=', 'null') ->count(); - $posts = Post::where('user_id', $user_id)->orderBy('date_post', 'DESC')->paginate(9); + $posts = Post::where('user_id', $user_id) + ->when(request('search', false), static function ($post, $search) { + return $post->where('content', 'like', '%'.$search.'%'); + }) + ->orderBy('date_post', 'DESC')->paginate(9); $today_post = Post::whereDate('date_post', '=', $today->format('Y-m-d')) ->where('user_id', $user_id) ->count(); diff --git a/app/User.php b/app/User.php index b7c1510..60bc353 100644 --- a/app/User.php +++ b/app/User.php @@ -42,4 +42,12 @@ class User extends Authenticatable $arrayHash = str_split(strtolower(md5($this->id))); return sprintf('%s/%s', $arrayHash[0], $arrayHash[1]); } + + /** + * @return bool + */ + public function isE2E() + { + return (bool) $this->encrypt_messages; + } } diff --git a/resources/views/layouts/connected.blade.php b/resources/views/layouts/connected.blade.php index ade6e4d..ee9b641 100644 --- a/resources/views/layouts/connected.blade.php +++ b/resources/views/layouts/connected.blade.php @@ -91,14 +91,16 @@
+ @if(!\Illuminate\Support\Facades\Auth::user()->isE2E())
- +
+ @endif