I am trying to query my database that is connected to my model "Address" to find any addresses that are 'LIKE' any input into my form in the address input field. My model code is:
public function CheckForPrevious($verify)
{
$matches = \App\Address::where('address', 'like', '%'.$verify.'%')
->get();
foreach($matches as $match)
{
echo "$match";
}
}
My controller code is:
public function show()
{
$address = new Address;
$check = $_POST['address'];
$address->CheckForPrevious($check);
return $address;
}
Any help would be greatly appreciated
scopecorrectly, take a look on the documentation laravel.com/docs/5.4/eloquent#local-scopespublic function CheckForPrevious($verify){$matches = \App\Address::where('address', 'like', '%'.$verify.'%')->get(); ` foreach($matches as $match){echo "$match";}}I get a return of an empty array