Download the PHP package touhidurabir/laravel-model-sanitize without Composer

On this page you can find all versions of the php package touhidurabir/laravel-model-sanitize. 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-model-sanitize

Laravel Model Sanitize

A simple package to sanitize model data to create/update table records.

Installation

Require the package using composer:

What is does ?

The Sanitize package sanitize the passed attributes to proper model fillables at create or update.

A model has table schema based multiple attributes associated with it. When we try to create a new model record or update an existing model record, we must provide the an array attributes that is propelry mapped to those arrtibute or table columns names . For example

The above code will run without any issue as both the email and password column presents in the users table . But for the following code

It will throw an \Illuminate\Database\QueryException if the data column not present in the users table.

The Sanitize package target to make it easier to handle such case as follow by including the Sanitizable trait in the models

The above code will work if the Sanitizable trait is used in the User model class. it will sanitize the passed attributed to model fillables and table columns, thus removing the extra or non useable attributes from it .

How it will be helpful ?

A great use case of this package is where one need to create multiple model instances from validated request data . For example

I personally use this appraoch in many of my laravel apps .

Usage

Use the trait Sanitizable in model where uuid needed to attach

And thats all . it will automatically work for all the following methods

This package also includes some helper methods that can be used to handle the sanitization process manually.

The sanitize static method will sanitize the given attributes list and retuen back the useable and valid attributes as an array

This will return back as such :

The gibberish static method will sanitize the given attributes list and retuen back the gibberish/non userbale attributes as an array

This will return back as such :

The sanitize and gibberish methods can be used to check or manually sanitize and evaluate the in valid data that can be passed to create/update model records.

It is also possible to disable/enable the sanitization process at the runtime using the static methods disableSanitization and enableSanitization . For example,

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT


All versions of laravel-model-sanitize with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.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 touhidurabir/laravel-model-sanitize contains the following files

Loading the files please wait ....