1. Go to this page and download the library: Download jochemict/larasearch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jochemict / larasearch example snippets
use JochemICT\Larasearch\Larasearchable;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Larasearchable;
/**
* The attributes that are searchable via Larasearch.
*
* @var array
*/
protected $searchable = ['name', 'email', 'city'];
}
public function index(Request $request)
{
$searchTerm = $request->input('search');
$users = User::search($searchTerm)->get();
return view('users.index', compact('users'));
}