vendredi 23 novembre 2018

Laravel undefined variable: search

Version of Laravel 5.0 and following is my code:

My form:

<form method="get" action="" class="search-wrap" >
    <div class="form-group">
        <input type="text" class="form-control search" placeholder="Search" name="key"/>
        <button class="btn btn-primary submit-search text-center" type="submit">
            <i class="icon-search"></i>
        </button>
    </div>
</form>

My controller:

use Illuminate\Http\Request;
use App\Http\Requests;
use App\products;

public function searchName(Request $request){
    $key = $request->key;
    $data = product::where('name','like','%'.$key.'%')->get();
    return view('footwear/result',['search'=>$data]);
}

My route:

Route::get('result', 'myControler@searchName');

My view:

<?php
    var_dump($search);
?>

I receive the following error: (Undefined variable: search)

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire