Skip to content

Instantly share code, notes, and snippets.

@raymond1988
Last active May 4, 2018 16:06
Show Gist options
  • Save raymond1988/ff3582c027daaacaa35ae1b1a0b747fd to your computer and use it in GitHub Desktop.
Save raymond1988/ff3582c027daaacaa35ae1b1a0b747fd to your computer and use it in GitHub Desktop.
It's implemented using the laravel form request feature which can be implemented with php artisan:make request command. The code within the rules function checks for validation issues.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreBlogPostRequest extends FormRequest {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules() {
return [
'title' => 'bail|required|max:255|unique:posts,title',
'description' => 'required|max:255',
'content' => 'required',
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment