Laravel Eloquent Search Filter Example

Today, We want to share with you Laravel Eloquent Search Filter.In this post we will show you How to implement search function in Laravel 6.2, hear for Searching models using a where like query in Laravel 6 we will give you demo and example for implement.In this post, we will learn about Build a live search feature with Laravel 6.2 and Vue.js with an example.

Laravel Eloquent Search Filter

There are the Following The simple About Create Live Search In Laravel Using AJAX Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel search multiple columns, so the Writing advanced Eloquent search query filters is used for this example is following below.

Step 1: Define a Laravel Route


Route::get('/find', '[email protected]');
Route::post('/retrivetickets', '[email protected]');

tep 2: Create Controller and Source code:-

Laravel Create Controller

php artisan make:controller TicketController


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Ticket;
use App\view;
use Illuminate\Support\Facades\Route;
use Validator, Redirect;
use Illuminate\Support\Facades\Auth;
use Session;
use Illuminate\Support\Facades\Input;
class TicketController extends Controller
	public function find()
	return view('tickets_list');			
	public function retrivetickets()
		$search = Input::get ( "search" );		
			$tickets = Ticket::where ( 'name', 'LIKE', '%' . $search . '%' )->orWhere ( 'destination', 'LIKE', '%' . $search . '%' )->get ();
		if (count ( $tickets ) > 0)
			return view ( 'tickets_list' )->withDetails ( $tickets )->withQuery ( $search );
			return view ( 'tickets_list' )->withMessage ( 'No tickets Details found. Try to search again !' );		

Step 3: Laravel Model code:-


namespace App;
use Illuminate\Database\Eloquent\Model;

class Ticket extends Model
   protected $table = 'tickets';
   protected $fillable = ['name','tid','destination','tnuom','pickup_dt'];

Step 4: view Source code


<!doctype html>

<form method="post" action="">				
<input type="text" name= "search">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button>Search Now</button>				
	 <table class="table table-striped">
            @foreach($details as $user)

Web Programming Tutorials Example with Demo

Read :

Also Read This ๐Ÿ‘‰   Alert Toast message in Angularjs Component


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel search form get method.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.