i"m using a mixture of 5.0.x and 5.1.x ... yeah I know ;-) but it works.
use Illuminate\Http\Request;
use App\Http\Requests\CreateRequest;
function
public function store(
CreateRequest $request
)
{
.
.
.
}
request
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateRequest 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 [
'name' => 'required',
'description' => 'required',
'status_id' => 'required'
];
}
}
view / partial ... whatever ;-)
@if ( $errors->any() )
<div class="alert alert-danger">
<strong>Whoops!</strong>
There were some problems with your input.
<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
With L4.x you had validation and put rules in your models and all that. With 5 came the Request bit so I now put all my rules into request files and things are sorted the way I like. 5.1.x is tad different but hopefully this will help you move to the 5 series at least.