Browse Source

Search implementation

master
Le Libre Au Quotidien 9 months ago
parent
commit
16a3d9c1da
  1. 2
      app/Http/Controllers/ContentController.php
  2. 6
      resources/views/master.blade.php
  3. 18
      resources/views/search.blade.php

2
app/Http/Controllers/ContentController.php

@ -38,7 +38,7 @@ class ContentController extends Controller
$query = request()->input('query');
$contents = Content::where('name','like',"%$query%")->orWhere('description','like',"%$query%")->get();
dd($contents);
//dd($contents);
return view('search')->with('contents', $contents);
}
}

6
resources/views/master.blade.php

@ -8,17 +8,13 @@
<nav>
<div class="nav-wrapper">
<a href="/" class="brand-logo">Infojune</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<nav>
<div class="nav-wrapper">
<ul id="nav-mobile" class="right">
<form method="get" action="{{ route('content.search') }}">
<div class="input-field">
<input name="query" id="search" type="search" required>
<label class="label-icon" for="search"><i class="fas fa-search"></i></label>
</div>
</form>
</div>
</nav>
</ul>
</div>
</nav>

18
resources/views/search.blade.php

@ -1,17 +1,13 @@
@extends('master')
@section('body')
<div id="choicebox">
<h3>Vous avez recherché : {{ request()->input('query') }}</h1>
<div class="cb-buttons">
@if ($items == null)
Aucun résultat
@endif
<div class="row center">
<h3>Vous avez recherché : {{ request()->input('query') }}</h3>
<div class="col s9">
@foreach ($contents as $content)
<a class="waves-effect waves-light btn-large" href="/content/{{ $content->href }}">
{{ $content->name }}
</a>
<a class="waves-effect waves-light btn-large" href="/content/{{ $content->href }}">
{{ $content->name }}
</a>
@endforeach
</div>
</div>
</div>
@endsection
Loading…
Cancel
Save