Is that some very old tutorial you are following?
use Illuminate\Http\Request;
Route::any ( '/search', function (Request $request) {
$q = $request->get('q');
if($q != ""){
$competition = Competition::where ( 'name', 'LIKE', '%' . $q . '%' )->orWhere ( 'email', 'LIKE', '%' . $q . '%' )->paginate (5)->setPath ( '' );
$pagination = $competition->appends ( array (
'q' => $request->get( 'q' )
) );
if (count ( $competition ) > 0)
return view ( 'welcome' )->withDetails ( $competition )->withQuery ( $q );
}
return view ( 'welcome' )->withMessage ( 'No Details found. Try to search again !' );
} );
I also highly recommend using a controller instead of putting the whole code in web.php