0% found this document useful (0 votes)
4 views

AutoComplete-Controller-File

Uploaded by

mayubasoftgeral
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

AutoComplete-Controller-File

Uploaded by

mayubasoftgeral
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\User;

class TypeaheadAutocompleteController extends Controller


{
function index()
{
return view('typeahead_autocomplete');
}

function action(Request $request)


{
$data = $request->all();

$query = $data['query'];

$filter_data = User::select('name')
->where('name', 'LIKE', '%'.$query.'%')
->get();

return response()->json($filter_data);
}
}

===================================================================

<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\TypeaheadAutocompleteController;

Route::get('/', function () {
return view('welcome');
});

Route::get('/typeahead_autocomplete', [TypeaheadAutocompleteController::class,
'index']);

Route::get('/typeahead_autocomplete/action',
[TypeaheadAutocompleteController::class, 'action'])-
>name('typeahead_autocomplete.action');

You might also like