Skip to content

Extending Capabilities

Shashank Jain edited this page Oct 1, 2016 · 1 revision

Laravel Rest API plugin provides various ways to override/extend default functionality.

Form Requests

If you use form requests for validation and authorization, you can use them with the plugin by giving referenced to the request classes as follows:

$indexRequest = UserIndexRequest::class;
$storeRequest = UserStoreRequest::class;

Similarly, for show, update, and delete methods.

Modifying Queries

You many want to modify queries for fetching and storing data, like, adding joins, inner queries, etc. You can to that by defining the corresponding modify functions. For example, to modify index request:

public function modifyIndex($query) {
    return $query->where("status", "active");
}
Clone this wiki locally