Download the PHP package mamadali/laravel-validation-models without Composer

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

Laravel Validation Models

Helps you easily validate your models and eloquent models with specific scenarios and use them in api

Latest Stable Version Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the "require" section of your composer.json file.


Basic Usage

First use trait in your model or eloquent model

in your form use like this

in your eloquent models use like this

then write your validation rules in validateRules() function in your model

and you can load data received from end user to your model and validate data \ ->validate() function return true or false

in eloquent models you can just call $model->save()

in save function call validate function by default \ if you need not call validate function

Advanced Usage

Multiple Models

you can new multiple model from your request data if your data list of models

Inline Validation

you can write your custom validation in your model \ write function name as validate{Attribute}() in your model

Scenarios

you can set multi scenarios for your model like this

and you can pass scenario when create your model

also you can set scenario on your model manually

when load attributes in your model only attributes in scenario set to your model

and you can get scenario currently your model on this


you can handle your validation rules with scenarios like this


Api Response

you can return your model data as response in your api \ in your api controller

in this order if your model has errors your response status code set to 422 and your error message in body \ else return your model attributes with value in body

in some api if you need No Content with 204 status code response you can use this function


you can customize your fields in api response with overwrite fields() function in your model like this

now supported cast type: int, string, float, bool


Get fields in api

you can write extra fields in your model like this

extra fields are not included in the api response by default \ and to get extra fields in the api response you need to add 'expand' parameter to your query params in request

in fields and extraFields method you can return recursively you model fields

\ in this request get all fields in fields() function and fields defined in 'expand' parameter

and you can get specific fields in your response by add 'fields' parameter in query params

\ in this request only get id,title and extraField1


Events

beforeValidate method is invoked before validation starts. \ You may override this method in your model \ If false is returned, the validation will stop and the model is considered invalid.

afterValidate method is invoked after validation ends. \ You may override this method in your model

beforeSave method is called at the beginning of inserting or updating a record in eloquent models. Override this method in your eloquent model \ If false, the insertion or updating will be cancelled.

This method is called at the end of inserting or updating a record in eloquent models. \ Override this method in your eloquent model:


All versions of laravel-validation-models with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/http Version >=8.0
illuminate/collections Version >=8.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 mamadali/laravel-validation-models contains the following files

Loading the files please wait ....