Browse Source

Search implementation

master
Le Libre Au Quotidien 2 months ago
parent
commit
16a3d9c1da
3 changed files with 9 additions and 17 deletions
  1. +1
    -1
      app/Http/Controllers/ContentController.php
  2. +1
    -5
      resources/views/master.blade.php
  3. +7
    -11
      resources/views/search.blade.php

+ 1
- 1
app/Http/Controllers/ContentController.php View File

@ -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);
}
}

+ 1
- 5
resources/views/master.blade.php View File

@ -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>

+ 7
- 11
resources/views/search.blade.php View File

@ -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