app/Http/Controllers/searchController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request)
    {
        $brands = Brands::all();
        $models = Models::all();
        $categories = Categories::all();
        $spares = null;
        $search = "";
        if ($request->searchName) {
            $search = $request->searchName;
            $spares = Spares::with('user', 'model', 'brand')
                ->where('description', 'LIKE', '%' . $request->searchName . '%')->orWhere('partNumber', 'LIKE', '%' . $request->searchName . '%')->get();
        }
        $spareCount=$spares->count();
        return View::make('browse')->with('spares', $spares)->with('sparesCount', $spareCount)->with('brands', $brands)->with('models', $models)->with('categories', $categories)->with('search', $search);
    }
public function index ( Request $ request ) { $ brands = Brands :: all ( ) ; $ models = Models :: all ( ) ; $ categories = Categories :: all ( ) ; $ spares = null ; $ search = " " ; if ( $ request -> searchName ) { $ search = $ request -> searchName ; $ spares = Spares :: with ( 'user' , 'model' , 'brand' ) -> where ( 'description' , 'LIKE' , '%' . $ request -> searchName . '%' ) -> orWhere ( 'partNumber' , 'LIKE' , '%' . $ request -> searchName . '%' ) -> get ( ) ; } $ spareCount = $ spares -> count ( ) ; return View :: make ( 'browse' ) -> with ( 'spares' , $ spares ) -> with ( 'sparesCount' , $ spareCount ) -> with ( 'brands' , $ brands ) -> with ( 'models' , $ models ) -> with ( 'categories' , $ categories ) -> with ( 'search' , $ search ) ; }
Display a listing of the resource.
Display a listing of the resource .