Today, We want to share with you Laravel 6 LIKE query example using Eloquent WHERE clause.In this post we will show you laravel collection where like, 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 Laravel 6 Eloquent WHERE LIKE query escaping with ‘%’ character with an example.
Laravel 6 LIKE query example using Eloquent WHERE clause
There are the Following The simple About laravel where likecase insensitive Full Information With Example and source code.
As I will cover this Post with live Working example to develop multiple like query in laravel6, so the laravel wherelike array is used for this example is following below.
laravel like query Examples
Simple SQL Example:
SELECT * FROM `users` WHERE `name` LIKE '%hdtopi%';
Laravel Query Example:
$search = 'hdtopi'; $user = User::where('name','LIKE',"%{$search}%")->get(); print_r($user);
Searching Eloquent models
Example 1
User::query() ->where('name', 'LIKE', "%{$searchTerm}%") ->orWhere('email', 'LIKE', "%{$searchTerm}%") ->get();
Example 2
BookingDates::where('email', Input::get('email')) ->orWhere('name', 'like', '%' . Input::get('name') . '%')->get();
Example 3
$data = DB::table('borrowers') ->join('loans', 'borrowers.id', '=', 'loans.borrower_id') ->select('borrowers.*', 'loans.*') ->where('loan_officers', 'like', '%' . $officerId . '%') ->where('loans.maturity_date', '<', date("Y-m-d")) ->get();
Example 4
Retrieve all posts with at least one comment containing words like foo%
$posts = Post::whereHas('comments', function ($query) { $query->where('content', 'like', 'foo%'); })->get();
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about laravel6 like query example.
I would like to have feedback on my infinityknow.com 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.