zaimealabs/searches

The ZaimeaLabs Searches package.

Fund package maintenance!
Custura

1.1 2025-03-25 10:43 UTC

This package is auto-updated.

Last update: 2025-03-26 09:24:34 UTC


README

Searches

Generate pdf in your application.

Searches Tests License

Hey 👋 thanks for considering making a donation, with these donations I can continue working to contribute to ZaimeaLabs projects.

Donate

Usage

    use ZaimeaLabs\Searches\Search;

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

Use ->when()

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

Multiple column

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

Search through relationships

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

Eager load relationships

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

Multi-words

    use ZaimeaLabs\Searches\Search;

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

Sorting

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

Paginate

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