Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/candasm/lafres
Laravel 5 Form Request Sanitizer
https://github.com/candasm/lafres
laravel-request laravel5 laravel5-package sanitization sanitizer
Last synced: 25 days ago
JSON representation
Laravel 5 Form Request Sanitizer
- Host: GitHub
- URL: https://github.com/candasm/lafres
- Owner: candasm
- License: mit
- Created: 2017-09-15T22:30:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-16T16:03:56.000Z (over 7 years ago)
- Last Synced: 2024-12-16T15:17:24.568Z (about 2 months ago)
- Topics: laravel-request, laravel5, laravel5-package, sanitization, sanitizer
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lafres(Laravel 5 Form Request Sanitizer)
#### Why I create this package?
Sanitizer support does not exists anymore on laravel framework. Actually which is not necessary when there is a validation for form inputs.
But when you want a simple functionality for form filtering ups! There is nothing to do rather then write a few lines.#### What it does?
Removes form keys which are not returning from rules method.#### Install
```
$ composer require candasm/laravel-form-request-sanitizer
```#### How to use it?
Just use `SanitizeWhenResolvedTrait` in your application abstract Request class.
```php
'required|unique:posts|max:255',
'body' => 'required',
];
}
}
```
For this case if you will receive post request like this:
```
[
'title' => 'test',
'body' => 'test',
'subject' => 'test',
]
```
And you wanna get all request parameters from `$request` variable(which is injecting to your controller method).
```php
...
public function store(StoreBlogPostRequest $request)
{
$attributes = $request->all();
$blogPost = BlogPost::create($attributes);
}
...
```
BlogPost model will receive only those parameters:
```
[
'title' => 'test',
'body' => 'test',
]
```