Download the PHP package lagumen/laravel-essentials without Composer
On this page you can find all versions of the php package lagumen/laravel-essentials. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lagumen/laravel-essentials
More information about lagumen/laravel-essentials
Files in lagumen/laravel-essentials
Package laravel-essentials
Short Description Laravel package that contains essential utilities in building a small to large scale projects
License MIT
Informations about the package laravel-essentials
Laravel Essentials
This package provides utilities that can help you build a small to large scale projects.
Inspired by Laravel Query Filters
Features
This package allows you to create Repositories
, Actions
, Validations
Class. It also features search, filtering and sorting functionality for your eloquent models.
Installation
Run the following command inside your project.
Optionally you can publish the config file by running the following command.
The config file contains the default namespace for Actions
, Validations
, Repositories
and Filters
. You can change the default namespace depending on your preference.
Usage
Repositories
You can create your Repository Class by running the following command.
This will create an Repository Class on App\Repositories
by default.
To apply this, just go ahead and initialize your Repository Class to your Controller.
Validations
Of course, you need to validate your request before inserting or updating a data in your database.
You can make your validation class by running the following command.
This will create a Validation Class on App\Http\Validations
by default.
To apply this, just go ahead and call the Validator
Facade inside your controller.
No need to create multiple Request Class for a single controller.
Actions
You can create your Action Class by running the following command.
This will create an Action Class on App\Actions
by default.
This will help you, make your controller to be managable and to look cleaner.
Filters
To allow your app to filter, search or sort data, just follow this guides..
First, let's create our Filter. You can do that by running the following command.
Notice that I used forward slash, this will create a class on App\Filters\User\Active.php
.
Next, let's apply the CanPerformSearch
trait on the model that you want to allow searching and set the columns that you want to allow to be searched, by calling $searchableColumns
.
You also need to call filter
scope on your model. You can do that by doing this.
Or, you can check what I did on the Repositories above. ;)
Now, you can perform filtering, searching and sorting by passing a request parameters to url: