Last active
August 29, 2015 14:24
-
-
Save JordanDalton/bb76ec99017fa9d0c637 to your computer and use it in GitHub Desktop.
Flexible errors with support for error bags.
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 $bag = isSet($bag) ? $bag : 'default';?> | |
@if( $errors->getBag($bag)->count() ) | |
<div class="alert alert-danger"> | |
@foreach( $errors->getBag($bag)->all() as $errorMessage ) | |
<p>{{ $errorMessage }}</p> | |
@endforeach | |
</div> | |
@endif |
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 App\Http\Requests\Request; | |
class StoreUserFormRequest extends Request | |
{ | |
/** | |
* The key to be used for the view error bag. | |
* | |
* @var string | |
*/ | |
protected $errorBag = 'yourBagName'; | |
/** | |
* 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 [ | |
// | |
]; | |
} | |
} |
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
@include('_errors', ['bag' => 'yourBagName']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment