Reputation: 1620
I am using Laravel 5. And I am a beginner.
In my OrganisationsController
I have a method
public function create()
{
return view('organisations.create');
}
In my routes.php
I have
Route::model('organisations', 'Organisation');
Route::resource('organisations', 'OrganisationsController');
In my create.blade.php
I have a code like this
<link href="{{ asset('css/style.css') }}" rel="stylesheet">
@extends('app')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Organisation</div>
<div class="panel-body">
@if (count($errors) > 0)
<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
<!--<form class="form-horizontal" role="form" method="POST" action="{{ url('/organisations/store') }}"> -->
<form class="form-horizontal" role="form" method="POST" action="{{ url('/organisations/store') }}" accept-charset="UTF-8">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}">
<div class="form-group">
<label class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">E-Mail</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
I need to validate email and name field
I don't know where to write a validation. Please suggest a example for this. I am using laravel 5. I have searched so many sites. But I cannot get solution for this. Please tell me where to write validation code.
Upvotes: 0
Views: 96
Reputation: 691
You should use FormRequest
for this:
http://laravel.com/docs/5.0/validation#form-request-validation
Upvotes: 1