Skip to content

Instantly share code, notes, and snippets.

@JordanDalton
Last active August 29, 2015 14:24
Show Gist options
  • Save JordanDalton/bb76ec99017fa9d0c637 to your computer and use it in GitHub Desktop.
Save JordanDalton/bb76ec99017fa9d0c637 to your computer and use it in GitHub Desktop.
Flexible errors with support for error bags.
<?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
<?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 [
//
];
}
}
@include('_errors', ['bag' => 'yourBagName'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment