Download the PHP package bayareawebpro/searchable-resource without Composer

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

Laravel Searchable Resource Builder

CI Coverage Downloads Version MIT

Searchable Resource Builder is an abstraction for building searchable resource responses in Laravel applications. Extract query logic into reusable chunks while using a fluent builder interface for dealing with searchable / filterable / sortable requests and JSON / API Resources.

Basic Usage

SearchableResources implement the Responsable interface which allows them to be returned from controllers easily. It can also be used with blade.

The method accepts instances of Eloquent Builder.

Ordering and Sorting

You can specify as many orderable columns as you wish.

The default settings:


Full Example


Blade / View Example

Execute the query and return a view with the items and options.


JSON Resources

SearchableResources are generic JsonResources by default. You can easily specify which resource class should be used to map your models when building the response.

Must extend JsonResource.


Invokable Queries

Queries are expressed as invokable classes that extend the AbstractQuery class which contains logic per request field. Queries can apply to multiple attributes/columns as well as multiple inputs for orWhere clauses.

php artisan make:searchable NameQuery

The following is an example of a generic name query:

ConditionalQuery Contract

Queries that implement the ConditionalQuery Contract will only be applied when their applies method returns true.

By default an query that extends AbstractQuery class using the ConditionalQuery contract already implements this method for you by calling the filled method on the request.
Override the parent method to customize.


Validation

Queries can specify their own validation rules by implementing the ValidatableQuery contract to be merged the rules for the searchable collection.

ValidatableQuery Contract

Queries that implement the ValidatableQuery Contract will have their returned rules merged into the validator, otherwise the rules will be ignored.

ProvidesOptions Contract

Queries can provide options that will be appended to the request options data by implementing the ProvidesOptions contract. This method should return a flat array of values that are injected into the response query options data.

Options Formatting

Options can be formatted with labels for usage with forms and filters by calling the labeled() method on the builder. The labeled method accept a boolean value which can be used to enable when the request has a session.

You can return preformatted options (label / value array) from queries or use the formatter to generate labeled options.

API Options Schema

Options for API requests are typically not-formatted for speed.

Blade Options Schema

Options for Blade requests can be formatted for usability.

FormatsOptions Contract

You can override the default formatter by specifying a formatter instance.

Setting Up Default Options

You can setup a resolving callback in a service provider to pre-bind options to every instance.


Adding Queries:

Queries can be added two ways. First by referencing the class string for easy bulk usage.

Second by instantiating each query using the make method. This can be useful when you need more methods and logic to determine usage.


Appendable Data

Attributes and fields can be appended to the response by using the following methods:

For model attributes:

For additional data (appended to the response):

For request fields (appended to the query in response):


When Condition Callback

You can use a callback or invokable class for more control with less method chaining.


Tap Callback

Useful for configuring the builder via an invokable class.


Response Output

The relevant query parameters and request options are appended to the output for convenience. Two additional properties have been added to the pagination parameters to remove the need for conditionals on the client / user side isFirstPage and isLastPage making pagination buttons easy to disable via props (Vue | React).

Note: If the pagination method is not used, all pagination related properties will be filtered from the output data.


Testing


All versions of searchable-resource with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
laravel/framework Version ^8.0|^9.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 bayareawebpro/searchable-resource contains the following files

Loading the files please wait ....