I'm trying to get a search bar to go through my database and grab all the numbers that include these 2 random numbers a user will input. The 2 consecutive numbers can be anywhere in the string and then it should grab the whole string. One issue I'm having is that the form is in the layout (maybe it doesn't matter, but i would still like to know how i can put the layout in a controller and include it in other methods)so it doesn't have it's own method and the form itself i'm trying to route to another view with the search results appearing. As of right now this is the error I'm getting: Missing argument 1 for App\Http\Controllers\SearchController::SearchEngine()
In my layout:
{!! Form::open(array('method' => 'GET', 'url' => 'search_engine')) !!}
<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>
{!! Form::close() !!}
In my Routes: `Route::get('search_engine', 'SearchController@SearchEngine');
In my controller:
public function SearchEngine($i)
{
$search = input::get('search');
$terms = explode(" ", $search);
$query = fsgdata::where('fsg_number')->get();
foreach($terms as $each) {
$i++;
if($i == 1) {
$query .= "fsg_number LIKE '%$each%' ";
echo $each;
}
else {
$query .= "0R fsg_number LIKE '%$each%' ";
}
}
// connect
mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DB_NAME");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0) {
while ($row = mysql_fetch_assoc($query)) {
$fsg_number = $row['fsg_number'];
echo "<h2>$fsg_number</h2>";
}
}
else {
}
// disconnect
mysql_close();
return View('Partials.search_form');
}
And my view is just another search bar etc.
Unfortunately, maybe I'm a dumb dumb, but laravels docs doesn't go into much detail about any of their features and instead choose to do a one and done example picture style. I'm new to laravel period so to me to task of filling in the dots can be very daunting.