Vantheman6
Vantheman6

Reputation: 1719

search query in laravel 5

I'm trying to get a search query to work in laravel 5, right now i just want it to pull exact match because i'm just desperate to get it to work, but eventually i want to find these 2 matching numbers in everything string of numbers that contains those 2. I tried various ways, but this is the latest way i attempted. FWI the searchbar is in my layout.
This is in layout:

{!! Form::open(array('method' => 'GET', 'url' => 'executeSearch')) !!}
        @include('Partials.search_form')
{!! Form::close() !!}

my searchbar form :

<div class="form-group">
    {!! Form::label('SEARCH:') !!}
    {!! Form::text( 'search', null, ['class' => 'form-control',
'        placeholder' =>'(NSN or PN)', 'size' => '20']) !!}
    {!! Form::submit('Submit', ['class' => 'btn btn-primary form-control']) !!}
</div>

This is my route:

Route::get('executeSearch', 'SearchController@executeSearch', function()
{
    $search = Input::get('search');
    session_start();
    $_SESSION['search'] = $search;
    DB::select('select * from fsgdatas where fsg_number = ?', array($search));

return('SearchController@executeSearch');

});

This is my controller

public function executeSearch()
{


    return View('Search_views.searchresults',compact('search'));
}

this is the searchresult view:

@extends('layout.master')
@section('content')
<div class="form-group">
    {!! Form::label('SEARCH:') !!}
    {!! Form::text( 'search', null, ['class' => 'form-control',
    'placeholder' =>'(NSN or PN)', 'size' => '20']) !!}
    {!! Form::submit('Submit', ['class' => 'btn btn-primary form-control']) !!}
</div>

<p>{{$name}}</p>
@endsection

This is my error: Undefined variable: name (View: /vagrant/leonis/resources/views/Search_views/searchresults.blade.php)

Upvotes: 1

Views: 628

Answers (1)

Chad
Chad

Reputation: 1818

You are not passing the name variable into the view. You are only passing search...

return View('Search_views.searchresults',compact('search'));

Upvotes: 4

Related Questions