1. Go to this page and download the library: Download diarsa/laravel-where-like 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/ */
diarsa / laravel-where-like example snippets
$search = $request->search;
return User::where('status', 1)
->where(function ($query) use ($search) {
$query->where('name', 'LIKE', "%{$search}%")
->orWhere('address', 'LIKE', "%{$search}%")
->orWhereHas('categoryDetail', function ($query) use ($search) {
$query->where('category_code', 'LIKE', "%{$search}%");
})
->orWhereHas('histories', function ($query) use ($search) {
$query->where('device', 'LIKE', "%{$search}%");
});
})
->get();
// Search in user's basic fields
User::whereLike(['name', 'email', 'phone'], $searchTerm)->get();
// Search in user and their profile information
User::whereLike([
'name',
'email',
'profile.bio',
'profile.location',
'posts.title',
'posts.content'
], $searchTerm)->get();
// Combine with other query conditions
User::where('status', 'active')
->where('created_at', '>=', now()->subMonth())
->whereLike(['name', 'email', 'profile.bio'], $searchTerm)
->orderBy('created_at', 'desc')
->paginate(10);
use Illuminate\Support\Collection;
$sensitiveData = collect(['[email protected]', '081234567890', 'SecretPassword123']);
// Default masking (shows first 2 and last 2 characters)
$masked = $sensitiveData->map(function ($item) {
return collect()->maskSensitiveData($item);
});
// Result: ['jo***@email.com', '08******7890', 'Se**********123']
// Custom masking (first 3 and last 1 characters)
$customMasked = $sensitiveData->map(function ($item) {
return collect()->maskSensitiveData($item, 3, 1);
});
// Result: ['joh******.com', '083*******0', 'Sec**********3']
$laravelWhereLike = new Diarsa\LaravelWhereLike\LaravelWhereLike();
echo $laravelWhereLike->tambah(1, 4);
use Diarsa\LaravelWhereLike\LaravelWhereLike;
Route::get('calculate', function() {
return LaravelWhereLike::tambah(1, 4);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.