Validation "in" Laravel 5

1

Good afternoon, I need to validate a DropDown so that if there are values 1, 2, 3 the user can not enter other values than the ones contained in it.

I was able to do in StudentUpdateRequest the following:

public function rules()
{
  return [
    'classe_id' => 'required|in:' . $this->aluno->classe_id,

In my StudentController.php it looks like this:

public function update(AlunoUpdateRequest $request, Aluno $aluno)
{
    $aluno->update($request->all());
    Session::flash('notice', 'Atualizado Com Sucesso !');
    return Redirect::to('/aluno');
}

The only problem is that I am not able to use the same form in creating the record in AlunoCreateRequest :

public function rules()
{
  return [
    'classe_id' => 'required|in:' . $this->aluno->classe_id,

The code is the same. How to solve?

UPDATE

I was able to solve this by using the "exists" function: link

    
asked by anonymous 27.05.2016 / 21:43

0 answers