Last active
August 29, 2015 14:24
-
-
Save thepsion5/f35d09ed9b5c8393671a to your computer and use it in GitHub Desktop.
Laravel Self-Validating Request Example
This file contains hidden or 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 MyAppName\Http\Requests\Members; | |
use Illuminate\Contracts\Validation\Validator; | |
use InternalPackage\Laravel\Traits\SessionFlashNotifierTrait; | |
use MyAppName\Http\Requests\Request; | |
class ImportMembersRequest extends Request | |
{ | |
use SessionFlashNotifierTrait; | |
private $rules = [ | |
'import_csv' => 'required|mimes:csv' | |
]; | |
public function rules() | |
{ | |
return $this->rules; | |
} | |
protected function failedValidation(Validator $validator) | |
{ | |
$this->notifyFailure('Unable to import members. Please check your input and try again.'); | |
return parent::failedValidation($validator); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment