Try
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Customer;
use Input;
class CustomerController extends Controller
{
public function index()
{
return view('customer');
}
public function autocomplete(Request $request)
{
$term = $request->input('name', '');
$data = Customer::where('name', 'LIKE', '%' .$term. '%')
->select(['name', 'id'])
->limit(5)
->get()
->toArray();
return response()->json($data);
}
// public function customer() {
// $customer = Customer::all();
// return view('customer', array('customer' => $customer ));
// }
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community