My required_if validation does not work. No error is output when "doubles" is selected but "team_mate2 and opponent2" are not selected. I need the form to require a second team mate and opponent when doubles is selected as the match type.
Match.php (Model)
<?php
class Match extends Eloquent{
protected $table = 'matches';
public static $rules = array(
'match_type'=>'required',
'associate'=>'alpha|min:2',
'location'=>'required|alpha|min:2',
'opponent'=>'numeric',
'team_mate2'=>'required_if:match_type,doubles',
'opponent2'=>'required_with:team_mate2'
);
public static $messages = array(
'opponent.numeric'=>'You must select a player.'
);
}
MatchController.php
public function postCreate()
{
$validator = Validator::make(Input::all(), Match::$rules, Match::$messages);
if ($validator->passes())
{
$datetime = Input::get('year')."-".Input::get('month')."-".Input::get('day')." ".Input::get('time').":00";
$match = new Match;
$match->type = Input::get('match_type');
$match->associate = Input::get('associate');
$match->date = $datetime;
$match->location = Input::get('location');
$match->save();
$matchp1 = new Matchplayer;
$matchp1->user_id = Input::get('id');
$matchp1->match_id = $match->id;
$matchp1->team = 1;
$matchp1->save();
$matchp2 = new Matchplayer;
$matchp2->user_id = Input::get('opponent');
$matchp2->match_id = $match->id;
$matchp2->team = 2;
$matchp2->save();
return Redirect::to('members/matches/create')->with('message', 'Match created!');
}else{
return Redirect::to('members/matches/create')->withErrors($validator)->withInput();
}
}
Match Create View
{{ Form::open(array('url'=>'members/matches/create', 'action' => 'post', 'class'=>'form-horizontal')) }}
{{ form::hidden('id', Auth::user()->id) }}
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Match Type</label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('match_type', '<span class="help-block">:message</span>') }}
{{ Form::select('match_type', array('singles' => 'Singles', 'doubles' => 'Doubles'), 'singles', array('id' => 'match_type', 'class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label for="gender" class="col-sm-5 control-label col-sm-pad">League Associate</label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('associate', '<span class="help-block">:message</span>') }}
{{ Form::text('associate', Input::old('associate'), array('class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Team Mate #1<br><small></small></label>
<div class="col-sm-7 col-sm-pad">
<p class="form-control-static">{{ Auth::user()->first_name." ".Auth::user()->last_name }}</p>
</div>
</div>
<div class="form-group{{ $errors->first('opponent', ' has-error') }}">
<label class="col-sm-5 control-label col-sm-pad">Opponent #1</label>
<div class="col-sm-7 col-sm-pad">
{{ Form::select('opponent', $users, 'key', array('class' => 'form-control input')) }}
{{ $errors->first('opponent', '<span class="help-block">:message</span>') }}
</div>
</div>
<div class="form-group{{ $errors->first('team_mate2', ' has-error') }}">
<label class="col-sm-5 control-label col-sm-pad">Team Mate #2<br><small>(Doubles Only)</small></label>
<div class="col-sm-7 col-sm-pad">
{{ Form::select('team_mate2', $users, 'key', array('class' => 'form-control input')); }}
{{ $errors->first('team_mate2', '<span class="help-block">:message</span>') }}
</div>
</div>
<div class="form-group{{ $errors->first('opponent2', ' has-error') }}">
<label class="col-sm-5 control-label col-sm-pad">Opponent #2<br><small>(Doubles Only)</small></label>
<div class="col-sm-7 col-sm-pad">
{{ Form::select('opponent2', $users, 'key', array('class' => 'form-control input')) }}
{{ $errors->first('opponent2', '<span class="help-block">:message</span>') }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Date</label>
{{ $errors->first('day', '<span class="help-block">:message</span>') }}
<div class="col-lg-2 col-sm-pad">
{{ Form::selectRange('day', 1, 31, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
<div class="col-lg-2 col-sm-pad">
{{ Form::selectRange('month', 1, 12, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
<div class="col-lg-3 col-sm-pad">
{{ Form::selectRange('year', 2014, 2015, 'a', array('class' => 'form-control input-sm input dob-form-control')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Time</label>
<div class="col-lg-3 col-sm-pad">
{{ Form::select('time', $times, 'key', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
</div>
<div class="form-group{{ $errors->first('location', ' has-error') }}">
<label class="col-sm-5 control-label col-sm-pad">Location</label>
<div class="col-sm-7 col-sm-pad">
{{ Form::text('location', Input::old('location'), array('class' => 'form-control input')) }}
{{ $errors->first('location', '<span class="help-block has-error">:message</span>') }}
</div>
</div>
{{ Form::submit('Create', array('class'=>'btn btn-success btn-block')) }}
{{ Form::token() . Form::close() }}
When I don't use a model like so:
$validator = Validator::make(
array('match_type' => Input::get('match_type')),
array('opponent' => 'required_if:match_type,doubles')
);
This seems to work. I still am unsure on why my method does not work, does the match_type value not pass over to required_if when in a Model?
Related
In my laravel application, I have a view to edit my non-admin users (participants) (via admin dashboard).
In this application, each user can add a pet too.
Once an admin goes to a certain participant's profile admin should be able to edit the participant and also the pet info as well if needed.
For that, I have to use two forms, one to update the user and another to update the pet. But both the forms are in a single view.
I've already created the participant controller (ParticipantController) and tested all the methods are working fine.
For the pets too I created a different model and a controller(PetsController).
But now I'm struggling to connect my pets controller to the participant edit blade.
following is the routing for the relevant scenario in my web.php
Route::group(['middleware' => ['auth']], function() {
Route::resource('/admins/roles','Admin\RoleController');
Route::resource('/admins/users','Admin\UserController');
Route::resource('/admins/participants','Admin\ParticipantController');
});
I've already created the participant's edit form which works properly and looking for some help to adding the petscontroller to the same blade.
following is my participants edit blade
#extends('layouts.admin')
#section('content')
<div class="row">
<div class="col-md-9">
<h2 class="view-title">{{ __('Edit User') }}</h2>
</div>
<div class="col-md-3">
<div class="text-left">
<!-- <a class="btn btn-primary btn-admin" href="{{ route('users.index') }}"> {{ __('Back') }}</a> -->
</div>
</div>
</div>
#if ($message = Session::get('success'))
<div class="alert alert-success">
<a class="close" onclick="jQuery('.alert').hide()">×</a>
<p>{{ $message }}</p>
</div>
#endif
<div class="row">
<div class="col-md-12" mt-5>
#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
</div>
</div>
{!! Form::model($user, ['method' => 'PATCH','enctype'=>'multipart/form-data','route' => ['participants.update', $user->id]]) !!}
<div class="row">
<div class="col-md-3 mt-5">
<!-- #if($user->image_id != 'default-avatar.png')
<button type="submit" name="resetphoto" class="btn btn-danger px-3 mr-5 pull-right"><i class="fa fa-trash" aria-hidden="true"></i>
</button>
#endif
-->
#if(empty($user->image_id))
<center> <img src="/propics/default-avatar.png" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
</p>
#else
<center> <img src="/propics/{{$user->image_id}}" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
#endif
<center><label for="propic" class="btn btn-default subscribe"><i class="fas fa-camera"></i></label></center>
<input id="propic" type="file" name="image_id" class="form-control">
<label id="file_name"></label>
#error('propic')
<span class="help-block" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="col-md-9 mt-5">
<div class="form-group row">
<div class="col-md-6">
{!! Form::text('first_name', null, array('placeholder' => 'First Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('first_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6">
{!! Form::text('last_name', null, array('placeholder' => 'Last Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('last_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="form-group row">
<div class="col-md-6 ">
{!! Form::text('email', null, array('placeholder' => 'Email','class' => 'form-control txt_txt')) !!}
{!! $errors->first('email', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6 ">
{!! Form::password('password', array('placeholder' => 'Password','class' => 'form-control txt_txt')) !!}
{!! $errors->first('password', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="form-group row">
<div class="col-md-6 ">
{!! Form::password('confirm-password', array('placeholder' => 'Confirm Password','class' => 'form-control txt_txt')) !!}
</div>
<div class="col-md-6">
{!! Form::select('roles[]', $roles,$userRole, array('class' => 'form-control','multiple')) !!}
{!! $errors->first('roles', '<span class="help-block" role="alert">:message</span>') !!}
{!! Form::text('role_id','null', array('class' => 'form-control txt_none')) !!}
{!! Form::text('gender','null', array('class' => 'form-control txt_none')) !!}
</div>
</div>
<div class="col-md-12 text-right px-0 ">
<a class="btn btn-primary btn-admin-form-cancel mt-5" href="{{ route('participants.index') }}"> {{ __('Cancel') }}</a>
<button type="submit" class="btn btn-primary btn-admin-form-save mt-5">{{ __('Save') }}</button>
</div>
</div>
</div>
{!! Form::close() !!}
<div class="row">
<hr class="black_line">
</div>
{!! Form::model($user, ['method' => 'PATCH','enctype'=>'multipart/form-data','route' => ['participants.update', $user->id]]) !!}
<div class="row">
<div class="col-md-3 mt-5">
<!-- #if($user->image_id != 'default-avatar.png')
<button type="submit" name="resetphoto" class="btn btn-danger px-3 mr-5 pull-right"><i class="fa fa-trash" aria-hidden="true"></i>
</button>
#endif
-->
#if(empty($user->image_id))
<center> <img src="/propics/default-avatar.png" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
</p>
#else
<center> <img src="/propics/{{$user->image_id}}" alt="Profile Pic" id="profile_pic_display_settings" class="mb-3"></center>
#endif
<center><label for="propic" class="btn btn-default subscribe"><i class="fas fa-camera"></i></label></center>
<input id="propic" type="file" name="image_id" class="form-control">
<label id="file_name"></label>
#error('propic')
<span class="help-block" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div class="col-md-9 mt-5">
<div class="form-group row">
<div class="col-md-6">
{!! Form::text('first_name', null, array('placeholder' => 'Pet Name','class' => 'form-control txt_txt')) !!}
{!! $errors->first('first_name', '<span class="help-block" role="alert">:message</span>') !!}
</div>
<div class="col-md-6">
{!! Form::text('pet_age', null, array('placeholder' => 'Pet Age','class' => 'form-control txt_txt')) !!}
{!! $errors->first('pet_age', '<span class="help-block" role="alert">:message</span>') !!}
</div>
</div>
<div class="col-md-12 text-right px-0 ">
<a class="btn btn-primary btn-admin-form-cancel mt-5" href="{{ route('participants.index') }}"> {{ __('Cancel') }}</a>
<button type="submit" class="btn btn-primary btn-admin-form-save mt-5">{{ __('Save') }}</button>
</div>
</div>
</div>
{!! Form::close() !!}
#endsection
I had developed a system that use maddhatter/laravel-fullcalendar.It works and i had no problem to display the calendar with the events.However, there is the problem that the calendar show all events include from different users.Can someone help me to solve this?
Controller
//show the events in the calendar
$events = Schedule::get();
$events->user()->id;
$event_list = [];
foreach ($events as $key => $event) {
$event_list[] = Calendar::event(
$event->event_name,
false,
new \DateTime($event->start_date),
new \DateTime($event->end_date),
null,
// Add color and link on event
[
'color' => '#05B06C',
//'url' => 'http://full-calendar.io',
]);
}
//Display Fullcalendar
$calendar_details = Calendar::addEvents($event_list)
->setOptions([ //set fullcalendar options
'firstDay'=> 1,
'editable'=> true,
'navLinks'=> true,
'selectable' => true,
'durationeditable' => true,
]);
return view('front.teacher.schedule.index', compact('calendar_details','events') );
}
Model
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Schedule extends Model
{
protected $fillable=[
'event_name','start_date','end_date'
];
}
View
{!! Form::open(array('route' =>'schedule:addEvents','method'=>'POST','files'=>'true'))!!}
<div class ="row">
<div class="col-xs-12 col-sm-12 col-md-12">
#if(Session::has('success'))
<div class="alert alert-success">{{Session::get('success')}}</div>
#elseif (Session::has('warning'))
<div class="alert alert-danger">{{Session::get('warning')}}</div>
#endif
</div>
<div class="col-xs-4 col-sm-4 col-md-4">
<div class="form-group">
{!! Form::label('event_name','Name:') !!}
<div class="">
{!! Form::text('event_name',null,['class'=>'form-control'])!!}
{!! $errors->first('event_name','<p class="alert alert-danger">:message</p>') !!}
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-sm-3">
<div class="form-group">
{!! Form::label('start_date','Start Date:')!!}
<div class="">
{!! Form::input('datetime-local','start_date',\Carbon\Carbon::now(),['class' => 'form-control']) !!}
{!! $errors->first('start_date', '<p class="alert alert-danger">:message</p>') !!}
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
{!!Form::label('end_date','End Date:')!!}
<div class="">
{!! Form::input('datetime-local','end_date',null, ['class' => 'form-control']) !!}
{!! $errors->first('end_date', '<p class="alert alert-danger">:message</p>') !!}
</div>
</div>
</div>
<div class="col-xs-1 col-sm-1 cold-md-1 text-center"> <br/>
{!! Form::submit('Add Event',['class'=>'btn btn-primary']) !!}
</div>
</div>
{!!Form::close() !!}
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">My Event Details</div>
<div class="panel-body">
{!! $calendar_details->calendar() !!}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endsection
#section('script')
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.js"></script>
{!! $calendar_details->script() !!}
Schedule Table
Table
I'm trying to update the fields in the database, but I couldn't
here is my routes :
Route::get('orders', [
'uses' => 'OrderController#postOrder',
'as' => 'order.show'
]);
here the controller:
public function postOrder()
{
$this->orderForm->validate(Input::all());
$order = $this->orders->getNew([
'link' => Input::post('link'),
'size' => Input::post('size'),
'color' => Input::post('color')
]);
$this->orders->save($order);
return Redirect::back()->withMessage('Order has been updated');
}
here is the blade:
{{ Form::open() }}
<div class="box-body">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('title', 'Product:') }}
{{ Form::text('title', $order->title, ['class' => 'form-control', ]) }}
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('link', 'Link:') }}
{{ Form::text('link', $order->link, ['class' => 'form-control']) }}
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('size', 'Size:') }}
{{ Form::text('size', $order->size, ['class' => 'form-control']) }}
</div>
</div>
<div class="col-lg-6">
</div>
</div>
<div class="box-footer">
{{ Form::submit('Save', ['class' => 'btn btn-primary']) }}
</div>
{{ Form::close() }}
so each time I try to update the order I got error "MethodNotAllowedHttpException ", I tried a lot of methods but I'm lost. I'm still beginner in php and this problem drive me crazy, so I'll be glad if you can help guys.
thanks
*** I've updated the code
So you're posting to the route, /orders. Therefor you need a HTTP POST request. You're now assigning a GET request to the /orders route.
You need to change your code to:
Route::post('orders', [
'uses' => 'OrderController#postOrder',
'as' => 'order.show'
]);
Also you need to add a CSRF Token, this can be done through adding {!! csrf_field() !!} in your blade (inside your Form open and close).
{{ Form::open() }}
{!! csrf_field() !!}
<div class="box-body">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('title', 'Product:') }}
{{ Form::text('title', $order->title, ['class' => 'form-control', ]) }}
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('link', 'Link:') }}
{{ Form::text('link', $order->link, ['class' => 'form-control']) }}
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
{{ Form::label('size', 'Size:') }}
{{ Form::text('size', $order->size, ['class' => 'form-control']) }}
</div>
</div>
<div class="col-lg-6">
</div>
</div>
<div class="box-footer">
{{ Form::submit('Save', ['class' => 'btn btn-primary']) }}
</div>
{{ Form::close() }}
Hope this works!
You must specify the method in the Form::open method.
{{ Form::open(array('method' => 'post')) }}
Just added this in the repository:
public function updateOrder($id, array $data)
{
$orders = $this->getById($id);
if (!empty($data['title'])) {
$orders->title = $data['title'];
}
if (!empty($data['link'])) {
$orders->link = $data['link'];
}
(AND SO ON)
$orders->save();
and in the controller:
public function postOrder($id)
{
$this->orders->updateOrder($id, Input::all());
return Redirect::back()->withMessage('Updated');
}
and that's it
I am using symfony2. Actually i have created form using form type. but when i render the form, following error occurred
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock() must be an instance of Symfony\Component\Form\FormView
Here is my code
Controller
$profile = new profile();
$myForm = $this->createForm(new ProfileFormType(), $profile);
return $this->render('ProfileBundle:Profle:profile.html.twig', array(
'form' => $myForm,
'vendor' => $vendor,
'productId' => $productId
));
profile.twig.html
<form action="{{ path('profile_new') }}" method="POST" {{ form_enctype(form) }} id="frmProfile">
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">First Name: </label>
{{ form_widget(form.firstName, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.firstName) }}</div>
</div>
</div>
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">Last Name: </label>
{{ form_widget(form.lastName, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.lastName) }}</div>
</div>
</div>
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">User Name: </label>
{{ form_widget(form.username, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.username) }}</div>
</div>
</div>
</form>
What am i doing wrong?
Replace 'form' => $myForm with 'form' => $myForm->createView(). Function createView() will create view of form object.
return $this->render('ProfileBundle:Profle:profile.html.twig', array(
'form' => $myForm->createView(), // << Add "->createView()"
'vendor' => $vendor,
'productId' => $productId
));
I'm trying to add a new match into the database but if I purposely don't enter anything into the form, no errors are displayed. I have based this on my registration form which works perfectly. If I correctly fill out the form all data goes into the database correctly.
MatchController.php
public function postCreate()
{
$validator = Validator::make(Input::all(), Match::$rules);
if ($validator->passes())
{
$datetime = Input::get('year')."-".Input::get('month')."-".Input::get('day')." ".Input::get('time').":00";
$match = new Match;
$match->type = Input::get('match_type');
$match->associate = Input::get('associate');
$match->date = $datetime;
$match->location = Input::get('location');
$match->save();
$matchp1 = new Matchplayer;
$matchp1->user_id = Input::get('id');
$matchp1->match_id = $match->id;
$matchp1->team = 1;
$matchp1->save();
$matchp2 = new Matchplayer;
$matchp2->user_id = Input::get('opponent');
$matchp2->match_id = $match->id;
$matchp2->team = 2;
$matchp2->save();
return Redirect::to('members/matches/create')->with('message', 'Match created!');
}else{
return Redirect::to('members/matches/create')->withErrors($validator)->withInput();
}
}
Match Model (Match.php)
class Match extends Eloquent{
protected $table = 'matches';
public static $rules = array(
'match_type'=>'required',
'associate'=>'alpha|min:2'
'location'=>'required|alpha|min:2',
'team_mate2'=>'required_if:match_type,doubles',
'opponent2'=>'required_with:team_mate2'
);
}
Match Creation View (matchCreate.php)
<div class="row clearfix">
<!-- Error Message Box -->
#if(Session::has('message'))
<div class="col-md-8 col-md-offset-2">
<div class="alert alert-info">{{ Session::get('message') }}</div>
</div>
#endif
<div class="col-md-9">
<!-- Top Menu BEGIN -->
<ul class="nav nav-pills nav-justified">
<li>{{ HTML::link('members/logout', 'Profiles') }}</li>
<li>{{ HTML::link('members/logout', 'Leagues') }}</li>
<li class="active">{{ HTML::link('members/logout', 'Add Match') }}</li>
<li>{{ HTML::link('members/logout', 'Results & Fixtures') }}</li>
<li>{{ HTML::link('members/logout', 'Matchboard') }}</li>
</ul>
<!-- Top Menu END -->
<div class="page-header">
<h3>Create a Match</h3>
</div>
<div class="col-sm-6">
{{ Form::open(array('url'=>'members/matches/create', 'action' => 'post', 'class'=>'form-horizontal')) }}
{{ form::hidden('id', Auth::user()->id) }}
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Match Type</label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('match_type', '<span class="help-block">:message</span>') }}
{{ Form::select('match_type', array('singles' => 'Singles', 'doubles' => 'Doubles'), 'singles', array('id' => 'match_type', 'class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label for="gender" class="col-sm-5 control-label col-sm-pad">League Associate</label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('associate', '<span class="help-block">:message</span>') }}
{{ Form::text('associate', Input::old('associate'), array('class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Team Mate #1<br><small></small></label>
<div class="col-sm-7 col-sm-pad">
<p class="form-control-static">{{ Auth::user()->first_name." ".Auth::user()->last_name }}</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Opponent #1</label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('opponent', '<span class="help-block">:message</span>') }}
{{ Form::select('opponent', $users, 'key', array('class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Team Mate #2<br><small>(Doubles Only)</small></label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('team_mate2', '<span class="help-block">:message</span>') }}
{{ Form::select('team_mate2', $users, 'key', array('class' => 'form-control input')); }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Opponent #2<br><small>(Doubles Only)</small></label>
<div class="col-sm-7 col-sm-pad">
{{ $errors->first('opponent2', '<span class="help-block">:message</span>') }}
{{ Form::select('opponent2', $users, 'key', array('class' => 'form-control input')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Date</label>
{{ $errors->first('day', '<span class="help-block">:message</span>') }}
<div class="col-lg-2 col-sm-pad">
{{ Form::selectRange('day', 1, 31, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
<div class="col-lg-2 col-sm-pad">
{{ Form::selectRange('month', 1, 12, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
<div class="col-lg-3 col-sm-pad">
{{ Form::selectRange('year', 2014, 2015, 'a', array('class' => 'form-control input-sm input dob-form-control')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Time</label>
<div class="col-lg-3 col-sm-pad">
{{ $errors->first('time', '<span class="help-block">:message</span>') }}
{{ Form::select('time', $times, 'key', array('class' => 'form-control input input-sm dob-form-control')) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-5 control-label col-sm-pad">Location</label>
<div class="col-sm-7 col-sm-pad">
{{ Form::text('location', Input::old('location'), array('class' => 'form-control input')) }}
</div>
</div>
{{ Form::submit('Create', array('class'=>'btn btn-success btn-block')) }}
{{ Form::token() . Form::close() }}
</div>
<div class="col-sm-6">
</div>
</div>
#include('includes.sidemenu')
</div>
routes.php
Route::post('members/matches/create', 'MatchController#postCreate');
You're creating your Validator object incorrectly. The make() method has four parameters:
/**
* Create a new Validator instance.
*
* #param array $data
* #param array $rules
* #param array $messages
* #return \Illuminate\Validation\Validator
*/
public function make(array $data, array $rules, array $messages = array(), array $customAttributes = array()) { ... }
You're passing each of your validation rules as a separate array, rather than together as one array. Subsequently, you aren't passing any of your input data, either, so it has no actual data to validate against.