Ajoute le moteur de recherche simple

Fix #11
This commit is contained in:
Clement Desmidt 2020-03-17 10:57:23 +01:00
parent 516d6d1d34
commit b54b9959cf
3 changed files with 16 additions and 2 deletions

View File

@ -44,7 +44,11 @@ class DashboardController extends Controller
$image_counts = Post::where('user_id', Auth::user()->getAuthIdentifier()) $image_counts = Post::where('user_id', Auth::user()->getAuthIdentifier())
->where('image', '!=', 'null') ->where('image', '!=', 'null')
->count(); ->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')) $today_post = Post::whereDate('date_post', '=', $today->format('Y-m-d'))
->where('user_id', $user_id) ->where('user_id', $user_id)
->count(); ->count();

View File

@ -42,4 +42,12 @@ class User extends Authenticatable
$arrayHash = str_split(strtolower(md5($this->id))); $arrayHash = str_split(strtolower(md5($this->id)));
return sprintf('%s/%s', $arrayHash[0], $arrayHash[1]); return sprintf('%s/%s', $arrayHash[0], $arrayHash[1]);
} }
/**
* @return bool
*/
public function isE2E()
{
return (bool) $this->encrypt_messages;
}
} }

View File

@ -91,14 +91,16 @@
<div class="header collapse d-lg-flex p-0" id="headerMenuCollapse"> <div class="header collapse d-lg-flex p-0" id="headerMenuCollapse">
<div class="container"> <div class="container">
<div class="row align-items-center"> <div class="row align-items-center">
@if(!\Illuminate\Support\Facades\Auth::user()->isE2E())
<div class="col-lg-3 ml-auto"> <div class="col-lg-3 ml-auto">
<form class="input-icon my-3 my-lg-0"> <form class="input-icon my-3 my-lg-0">
<input type="search" class="form-control header-search" placeholder="Search…" tabindex="1"> <input type="search" class="form-control header-search" name="search" placeholder="Search…" tabindex="1">
<div class="input-icon-addon"> <div class="input-icon-addon">
<i class="fe fe-search"></i> <i class="fe fe-search"></i>
</div> </div>
</form> </form>
</div> </div>
@endif
<div class="col-lg order-lg-first"> <div class="col-lg order-lg-first">
<ul class="nav nav-tabs border-0 flex-column flex-lg-row"> <ul class="nav nav-tabs border-0 flex-column flex-lg-row">
@include(config('laravel-menu.views.bootstrap-items'), ['items' => $menu->roots()]) @include(config('laravel-menu.views.bootstrap-items'), ['items' => $menu->roots()])