Download the PHP package johnylemon/laravel-searchable without Composer

On this page you can find all versions of the php package johnylemon/laravel-searchable. 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-searchable

Filter CRUD resources using simple query parameters

GitHub Workflow Status GitHub tag (latest by date)

This library makes searching and filtering super easy. Simplicity is a magic.

Getting started

  1. Add repository
  1. Register Johnylemon\Searchable\Providers\SearchableServiceProvider provider if not registered automagically .

  2. Publish config using publish command

  3. Add Johnylemon\Searchable\Traits\Searchable trait any model you want and searchable method defining searchable properties

  4. Enjoy!

Basic usage

To enable searching for current query use withSearch scope:

Example presented below will return all users named John

This will return users with name set to John and nick set to johnylemon

Sometimes you may want to pass many possible values. To achieve that use array of values for given property.

This example will return all users with name johny OR lemon, and nick set to johnylemon. Every possible name value will use filter defined for name property.

Of course you may pass arrays fo more than one property.

This example will return all users with name johny OR lemon, and nick set to johnylemon OR laravel.

Default search filter

By default every property will be filtered using Johnylemon\Searchable\Search\BasicSearch search filter. This filter will use simple where("property", "value") condition. Feel free to change this setting in your config file.

This package ships with some handy search filters, that may be used for common searching:

Like search filter

Uses Johnylemon\Searchable\Search\LikeSeach class. Will add %LIKE% condition.

LikeBegin search filter

Uses Johnylemon\Searchable\Search\LikeBeginSeach class. Will add LIKE% condition.

LikeEnd search filter

Uses Johnylemon\Searchable\Search\LikeEndSeach class. Will add %LIKE condition.

Feel free to use them for your searchables.

Customizing searchables

Searchable array may return more complex array than simple property names.

You may define which filter should be used for every field:

Note that full_name field does not exist in the database.

Aliases

Sometimes it may be handy to hide real column names in your search query. This is where aliases comes to play. Example presented above used two fields that does not exist in the database: full_name and name.

The full_name property uses anonymous function that will use simple concatenation for searching for given value.

The name property points to first_name property, so it will be treated as first_name field. Of course first_name must be searchable.

If you would like to use name field to be used as first_name field BUT WITHOUT making first_name searchable, just use custom Search class or anonymous function:

And this simple example will search for ghost users, thanks to aliases:

Shorthands

Of course typing entire class name or callables each time may be cumbersome, so this package allows you to define custom, easy to type and remember shorthands within your config file.

Shorthands takes precedence over field names. Lets assume you have name field, and username field that points to name field, and there is also name shorthand. In that case shorthand will be used instead of name field.

Build-in search filters also can be used as like, like-begin, and like-end shorthands.

Commands

This package ships with searchable:generate command, which can be used to rapid generating custom filter classes.

This command will place brand new class in directory specified in config file.

Testing

You can run the tests with:

License

The MIT License (MIT)

Contact

Visit me at https://johnylemon.dev


Developed with ❤ by johnylemon.


All versions of laravel-searchable with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^7.0 || ^8.0
johnylemon/miscellaneous Version ^0.1.0
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 johnylemon/laravel-searchable contains the following files

Loading the files please wait ....