Download the PHP package sim-vzla/laracruds without Composer

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

Build Status

Laracruds

A repository pattern helpers and validators for Laravel Framework

This package can help you be more productive when writing cruds for eloquent models providing you with a simple but powerful set of tools.

Instalation
composer require sim-vzla/laracruds

Then add the:

Laracruds\LaracrudsServiceProvider::class

to your providers array in config/app.php. To publish the config files use:

php artisan vendor:publish --provider="Laracruds\LaracrudsServiceProvider"
Usage

Lets say you wanna create a User model repository. Well then just extend the base repository class of the package:

This class have some CRUD methods for you:

You can find more info about them in the api reference.

Till now everything is pretty standard, but here comes the magic:

The EloquentRepository class takes an optional second parameter that expects and instance of Laracruds\BaseValidator to validate the data in the create and update methods. But if you don't provide one the class is gonna use the name of the model class and its gonna try to find one for you (using the parameters contained in the config file).

So by default if your passing an instance of App\User to the constructor of EloquentRepository the class is gonna assume there is a UserValidator located in `App\Helpers\Validators' folder.

Validation

A validation class is gonna look like this:

You just need to put the rules (from the ones availables by defult in laravel) you wanna apply in the method, Laracruds is gonna take of using them when needed.

But we wanna be able to use the same rules array for creation and update. So thats leaves us with the problem of required and unique rules... Dont worry... we already solved this for you: When the method of the class is called in the update method all the rules are removed dinamically from the array, just be sure to make it the first rule you declare in they keys that use it:

'email' => 'required|email',
'name' => 'required|string'

and to avoid the unique rules on update you just need to append the $id parameter received automatically by the function to the end of the array key. Just be sure to place the unique rule at the end of the key like this:

    public function rules($id)
    {
        return [
            'email' => 'required|email|unique:users,email,'.$id,
            'password' => 'required|min:6'
        ];
    }

To get validation errors just retrive the validator from the repository class with the method:

$validator = $repository->getValidator()

and then call the errors method:

$validator->errors();

All versions of laracruds with dependencies

PHP Build Version
Package Version
No informations.
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 sim-vzla/laracruds contains the following files

Loading the files please wait ....