Last active
May 4, 2018 16:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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