Download the PHP package anthonyedmonds/laravel-find without Composer

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

laravel-find

Find models within your Laravel system with minimal overhead

Installation

Add this library using composer require anthonyedmonds/laravel-find.

The service provider will be automatically registered.

Export the config file using php artisan vendor:publish --provider="AnthonyEdmonds\LaravelFind\FindServiceProvider"

Configuration

There are a small number of options that need to be configured prior to using the library.

anything-key / anything-label

Users are able to find Models across any that they have access to.

The key and label are controlled using these keys.

Set the key to false to disable searching across Models.

base-table

Searching across all models requires a base query upon which all others are joined.

Set this value to the name of a table which is guaranteed to exist in the system, such as the 'users' table.

models

This list controls which Models can be found using this library.

Each Model type to be found should be keyed with a plural label, with the Model class as the value.

Usage

This library is split into two parts, a Findable trait which is used on the Models to be found, and a Find static class which is used to get results.

Findable

Each Model listed in the models config key must use the Findable trait. This will add a number of abstract static methods which must be implemented.

findDisplayLabel

The display label for the Model type, such as "Authors by name and book title".

Used primarily for generally identifying the Model, preferably with context around which terms users can find by.

canBeFoundBy

Used to determine whether the current user (or null, if not signed in) can find a type of Model.

This logic will show or hide the entire Model type based on a true or false return.

The Find helper will throw an AuthorizationException if a user attempts to find a Model they are not allowed to.

findLabel

The primary identifier for the result, which can be:

findDescription

A brief description of the result, which can be:

findLink

The URL where the result can be found, which can be:

findFilters

The filters to be applied to the search, such as ->where('name', '=', $term).

As this library uses Laravel's QueryBuilder, you can use related Models to find results by performing a leftJoin with a matching where statement:

You may utilise the $user parameter to further refine the search to the current user.

Find

Once the Findable trait has been implemented on each Model you may use the Find helper to get results.

Most implementations will need to provide two pages to end users:

The start page should provide a text-box for the find term, and a drop-down to select which type of thing to find.

The results page should show a list of whatever was found.

Find::findBy

Calling findBy($term, $type) will construct and return a QueryBuilder statement which is ready to be executed.

As it is a standard query, you may extend the query as required, such as adding an order().

Run the query using whichever QueryBuilder method you require, such as paginate() or get().

This will return a standard Collection object containing the results.

Each result will have a label, description, and link attribute.

Find::types

Calling types() will return a list of Models which the current user can find.

This list can be used to populate a dropdown when starting a find to narrow the types of Models to locate, and identify the Models that the user is allowed to find.

The returned array is keyed using the keys from the config models.

By default, the value is each Model's findDisplayLabel(). Passing true to the method will instead return the Model class.

FindRequest

A Laravel FormRequest is provided for convenience called FindRequest.

Simply use it on controller methods for handling searches:

FindDate

Easily format dates entered by users in multiple formats into MySQL compatible fuzzy search terms.

Dates must have at least two parts, delimited by a non-numeric character.

Non-year Single part and invalid dates will be returned as false.

Users should be prompted to search in day-month-year order, with at least two parts of the date.

Year-month-day is supported where a four-digit year is provided.

Two digit and single digit dates have been catered for where the dates may conflict.

Support for leading zeroes has been included where possible.

Roadmap


All versions of laravel-find with dependencies

PHP Build Version
Package Version
Requires php Version ^8
illuminate/support Version ^12
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 anthonyedmonds/laravel-find contains the following files

Loading the files please wait ....