PHP code example of zaimealabs / searches

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

    

zaimealabs / searches example snippets


    use ZaimeaLabs\Searches\Search;

    $results = Search::in(User::class, 'name')
        ->search('Custura');

    Search::new()
        ->when($user->isAdmin(), fn($search) => $search->in(User::class, 'name'))
        ->search('Custura');

    Search::in(User::class, ['name', 'username'])
        ->search('Custura');

    Search::in(User::class, ['posts.title'])
        ->search('laravel');

    Search::in(Post::with('comments'), 'title')
        ->in(Video::with('likes'), 'title')
        ->search('laravel');
 
    use ZaimeaLabs\Searches\Search;

    Search::in(Blog::class, 'title')
        ->in(Video::class, 'title')
        ->search('"laravel livewire alpine"');

    ->orderByDesc()

    ->orderByRelevance()

    ->orderByModel([Post::class, Video::class,])

    ->paginate()
    
    ->paginate($perPage = 10, $pageName = 'page', $page = 1)
    # OR
    ->simplePaginate()
    
    ->simplePaginate($perPage = 10, $pageName = 'page', $page = 1)