PHP code example of touhidurabir / eloquent-wherelike

1. Go to this page and download the library: Download touhidurabir/eloquent-wherelike 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/ */

    

touhidurabir / eloquent-wherelike example snippets


$users = User::whereLike(['email', 'name'], 'search_term')->get();

$users = User::whereLike(
    [
        'email', 
        'name',
        '.profile[first, last_name]'
    ], 'search_term'
)->get();

'.profile[first, last_name]'

$campaigns = $campaigns->whereLike(
    [
        'title', 
        'description',
        '.user.profile[first_name, last_name]',
        '.categories[name]',
        '.campaigntype[title]',
        '.team[name]'
    ], 
    $search
)->get();

$campaigns = $campaigns->where(function ($query) use ($search) {
    $query
        ->where('title', 'LIKE', '%' . $search . '%')
        ->orWhere('description', 'LIKE', '%' . $search . '%')
        ->orWhereHas('user', function($query) use ($search) {
            $query->whereHas('profile', function($query) use ($search) {
                $query->where('first_name', 'LIKE', '%' . $search . '%')
                ->orWhere('last_name', 'LIKE', '%' . $search . '%');
            });
        })
        ->orWhereHas('categories', function($query) use ($search) {
            $query->where('name', 'LIKE', '%' . $search . '%');
        })
        ->orWhereHas('campaigntype', function($query) use ($search) {
            $query->where('title', 'LIKE', '%' . $search . '%');
        })
        ->orWhereHas('team', function($query) use ($search) {
            $query->where('name', 'LIKE', '%' . $search . '%');
        });
})->get();
bash
php artisan vendor:publish --provider="Touhidurabir\EloquentWherelike\EloquentWherelikeServiceProvider" --tag=config