Support the ongoing development of Laravel.io →
Requests Input Database
Last updated 2 years ago.
0

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 ));
    // }
}
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ciel01 ciel01 Joined 22 Jun 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.