albertcht / lumen-form-request by albertcht
forked from ssi-anik/form-request

Form request is a package for Lumen that lets developer validate form requests like Laravel does.
14,839
10
2
Package Data
Maintainer Username: albertcht
Maintainer Contact: albert.cht@gmail.com (Albert Chen)
Package Create Date: 2017-12-29
Package Last Update: 2020-04-22
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:11:02
Package Statistics
Total Downloads: 14,839
Monthly Downloads: 1
Daily Downloads: 1
Total Stars: 10
Total Watchers: 2
Total Forks: 8
Total Open Issues: 2

Lumen Form Request

php-badge packagist-badge Total Downloads

Description

A package that helps developer to segregate the validation logic from controller to a separate dedicated class. Lumen doesn't have any FormRequest class like Laravel. This will let you do that.

Installation

composer require albertcht/lumen-form-request
  • Add the service provider in bootstrap/app.php
$app->register(AlbertCht\Form\FormRequestServiceProvider::class);

Next step is create your FormRequest and extends from AlbertCht\Form\FormRequest

Example

<?php

namespace App\Http\Requests;

use AlbertCht\Form\FormRequest;

class StoreDeviceRequest extends FormRequest
{
	public function authorize()
	{
		return true;
	}

	public function rules()
	{
		return [
			'mac_address' => 'required|unique:devices,mac_address'
		];
	}
}