LaravelPackages.net
Acme Inc.
Toggle sidebar
zaratedev/laravel-excludable

Exclude the provided elements from the query results.

6
2
v1.0.1
About zaratedev/laravel-excludable

zaratedev/laravel-excludable is a Laravel package for exclude the provided elements from the query results.. It currently has 2 GitHub stars and 6 downloads on Packagist (latest version v1.0.1). Install it with composer require zaratedev/laravel-excludable. Discover more Laravel packages by zaratedev or browse all Laravel packages to compare alternatives.

Last updated

Laravel Excludable

Latest Version on Packagist Total Downloads GitHub Actions

Banner

This package allow to your eloquent models apply exclude provides elements from the query results.

Installation

You can install the package via composer:

composer require zaratedev/laravel-excludable

Usage

Use the Excludable trait in any Eloquent Model.


use Illuminate\Database\Eloquent\Model;
use ZarateDev\LaravelExcludable\Excludable;

class User extends Model
{
    use Excludable;
}

Now you have available scope exclude() method in Eloquent Model.


use App\Models\User;

class UserController extends Controller
{
    public function index()
    {
        $user = auth()->user();

        $users = User::query()->exclude($user)->get();

        return view('users.index', compact('users'));
    }
}

The method exclude can recieved attribute of type collection, model, integer, array. For more examples see test suits.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Star History Chart