Laravel Problem with passing parameters to Controllers

0

So I have a relevant problem. I need to create a link to the controller.edit to edit clear a value in the database. I've tried practically everything. But I keep getting an error:

  

htmlspecialchars () expects parameter 1 to be string, array given (View: /var/www/html/project/resources/views/aluno.blade.php)

I am currently using Forms & HTML from laravel and opened a form of pointing pro edit:

{!! Form::open(['route'=>['aluno.edit', $aluno->id],'method'=> 'get']) !!}
      {!! Form::submit('Editar',['class'=>'btn btn-danger', 'id'=>'bt'])!!}
      {!! Form::close() !!}

My controller:

public function edit($id){
$aluno = $this->aluno->find($id);
return view('aluno', compact('aluno'));

}

In my view aluno.blade.php:

 @if (isset($aluno))
          {!! Form::model($aluno,['route'=>['aluno.update',$aluno->id],'class'=>'form-horizontal m-t-20','method'=>'PUT']) !!}
        @else
          {!! Form::open(['route'=>['aluno.store'],'method'=>'post','class'=>'form-horizontal m-t-20']) !!}
        @endif

Already tried to go through link:

<a href="{{route('aluno.edit',$aluno->id)}}" class="edit actions "><span></span> </a>

I always get the same error saying that a string was expected and step an array

I use the same for the destroy method and works perfectly:

{!! Form::open(['route'=>['aluno.destroy', $aluno->id], 'method'=> 'DELETE']) !!}
      {!! Form::submit('Apagar',['class'=>'btn btn-danger', 'id'=>'bt'])!!}
      {!! Form::close() !!}

I am doing some tests, it seems that this error is coming due to Forms, I pointed to another controller ex:

 {!! Form::open(['route'=>['instrutor.edit', $aluno->id],'method'=> 'get']) !!}
      {!! Form::submit('Editar',['class'=>'btn btn-danger', 'id'=>'bt'])!!}
      {!! Form::close() !!}

And it opened normally so follow my student view

                                              New Student           

      <div class="">
        @if (isset($aluno))
          {!! Form::model($aluno,['route'=>['aluno.update',$aluno->id],'class'=>'form-horizontal m-t-20','method'=>'PUT']) !!}
        @else
          {!! Form::open(['route'=>['aluno.store'],'method'=>'post','class'=>'form-horizontal m-t-20']) !!}
        @endif


          @if (isset($errors) && count($errors)>0)
              <div class="alert alert-danger">
                  @foreach ($errors->all() as $error)
                      <p> {{$error}} </p>
                  @endforeach
              </div>
          @endif

          <div class="form-group">
            {!! Form::label('nome', 'Nome', ['class' => 'control-label','for'=>'nome']) !!}
            {!! Form::text('nome',"",['class'=>'form-control','required','id'=>'nome']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('cpf','CPF',['class'=>'control-label','for'=>'cpf']) !!}
            {!! Form::text('cpf',"",['class'=>'form-control','required','id'=>'cpf']) !!}
          </div>
          <div class="form-group">
            {!! Form::label('email','Email',['class'=>'control-label','for'=>'email']) !!}
            {!! Form::email('email',"",['class'=>'form-control','required','id'=>'email']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('data_nascimento','Data de Nascimento',['class'=>'control-label','for'=>'data_nascimento']) !!}
            {!! Form::date('data_nascimento',"",['class'=>'form-control','required','id'=>'data_nascimento']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('telefone','Telefone',['class'=>'control-label','for'=>'telefone']) !!}
            {!! Form::text('telefone',"",['class'=>'form-control','id'=>'telefone']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('celular','Celular',['class'=>'control-label','for'=>'celular']) !!}
            {!! Form::text('celular',"",['class'=>'form-control','required','id'=>'celular']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('cep','Cep',['class'=>'control-label','for'=>'cep']) !!}
            {!! Form::text('cep',"",['class'=>'form-control','required','id'=>'cep']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('estados','Estado',['class'=>'control-label','for'=>'estados']) !!}
            {!! Form::text('estados',"",['class'=>'form-control','required','id'=>'estados']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('cidade','Cidade',['class'=>'control-label','for'=>'cidaade']) !!}
            {!! Form::text('cidade',"",['class'=>'form-control','required','id'=>'cidade']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('bairro','Bairro',['class'=>'control-label','for'=>'bairro']) !!}
            {!! Form::text('bairro',"",['class'=>'form-control','required','id'=>'bairro']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('rua','Rua',['class'=>'control-label','for'=>'rua']) !!}
            {!! Form::text('rua',"",['class'=>'form-control','required','id'=>'rua']) !!}

            {!! Form::label('numero','Número',['class'=>'control-label','for'=>'numero']) !!}
            {!! Form::text('numero',"",['class'=>'form-control','required','id'=>'numero']) !!}
          </div>

          <div class="form-group">
            {!! Form::label('dataini','Data Matricula',['class'=>'control-label','for'=>'dataini']) !!}
            {!! Form::date('dataini',"",['class'=>'form-control','required','id'=>'dataini']) !!}
          </div>

          <div class="form-group text-right m-t-20">
            <div class="col-xs-12">
              @if (isset($aluno))
                {!! Form::submit('Editar',['route'=>['aluno.edit',$aluno->id] ,'class'=>'btn btn-danger', 'id'=>'btn']) !!}
              @else
                {!! Form::submit('Cadastrar',['route'=>'aluno.store','class'=>'btn btn-primary btn-just-icon', 'id'=>'btn']) !!}
              @endif
                {!! Form::reset('Limpar',['class'=>'btn btn-default btn-just-icon', 'id'=>'bt']) !!}
            </div>
          </div>
        {!! Form::close() !!}
      </div>
    </div>
  </div>
</div>

@endsection

    
asked by anonymous 08.10.2017 / 20:47

0 answers