Download the PHP package backfron/laravel-finder without Composer

On this page you can find all versions of the php package backfron/laravel-finder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-finder

LaravelFinder

backfron/laravel-finder provides an easy way to build complex database searchs in a scalable way using ELoquent. If you have a form with a bunch of fields by which you must filter your data, LaravelFinder maybe suit your needs.

These package was inspired by Amo Chohan's article.

Installation

Via Composer

Usage

Finders

Lets imagine that we need to build a search feature for tasks. You have a Task model and want to perform a query by one or many conditions like: status, creation date, owner, finish date, etc. To To do so, you may create a Finder. A Finder is basicaly a class where we can define the model for which we will be building the search. LaravelFinder offers an artisan command for quickly scaffold Finders.

These command will create a new Finder located at app/Finders/Tasks/TaskFinder.php. If you inspect the file you will see that is a very short class that basically stores the model with which we will build the query.

Filters

Next we need to create the Filters. Filters are where we will write the logic for our query. Each filter should handle a single field condition. For example, if we need to search a Task by their status, we just need to create a filter for that purpouse. LaravelFinder offers an artisan command for quickly scaffold your filters. You must specify the name of the Filter and the model to which it will be applied. The name of the filter idealy should match with the field name in your database table.

These command will create a file located at app/Finders/Tasks/Filters/Status.php. These file contains a class and a method called apply that receives an instance of the Eloquent query builder (\Illuminate\Database\Eloquent\Builder) and the value with which the search will be performed.

Of course, you can modify the query to fit your needs. For example:

You can create as many Filters as you need. So for example imagine we created the filters: Status, UserOwnerId and FinishedAt. Then in your controller you can receive a request that includes those fileds in snake_case version, and pass it to the filters static method of your Finder.

Under the hood, LaravelFinder will take the field names and will call the appropriate Filter. For status field the Status filter will be called, for user_owner_id field the UserOwnerId filter will be called, for the finished_at field the FinishedAt field will be called an so on.

After setting your filters, you can even call any method that you would normally call in your model instance, that means you can continue chaining Eloquent methods after applying your filters.

What happen if a field don't have a match Filter? No worries, by default LaravelFinder will ignore any field that don't match with any of the available filters. You can change these behavior by publishing the config file laravel-finder.php like these:

And once the config file is published at config/laravel-finder.php, you may set to false the ignore-unexisting-filters key. When set to false LaravelFinder will throw an Backfron\LaravelFinder\Exceptions\FilterNotFoundException exception if you include a filter that don't exists yet.

You even can create your Finder and your filters in one command call.

Global filters

If you want to apply a global filter to your query, you can do it through the global method and passing a Closure as parameter.

In case you want to use some of your created filters as a global filter you can do it like this:

TODO

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

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

Credits

License

Please see the license file for more information.


All versions of laravel-finder with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ~11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package backfron/laravel-finder contains the following files

Loading the files please wait ....