htmlentities () expects parameter 1 to be string, object given

0

I have a problem sending a query in a select it marks me the error htmlentities () expects parameter 1 to be string, object given

My Controller is this:

        $works = ContractWork::get();
        $year = DB:: table('contract_works')
            ->select(DB::raw('Year(dateFailure) as dt'))
            ->groupBy('dt')
            ->orderBy('dt','asc')
            ->get();


            $thearray = (array) $year;

        return view('contratoObra.index',compact('works','year'));

My view where I send the variable is as follows:

{!!Form::open(['route' => 'contratoObra.index', 'method' => 'GET', 'class' => 'navbar-form navbar-right pull-right'])!!}
<div class="form-group" >
  <div class="col-md-2 form-group">
    {!!Form::select('year', $year, null, ['placeholder' => 'Todo...' ])!!}
  </div>
</div>
{!!Form::submit('Filtrar',['class'=>'btn btn-primary'])!!}
{!!Form::close()!!}
    
asked by Daniel Cruz Pablo 04.05.2016 в 02:40
source

1 answer

0

Use the toArray() method to convert the collection to an array: link

/**
 * Get the collection of items as a plain array.
 *
 * @return array
 */
public function toArray()
{
    return array_map(function ($value) {
        return $value instanceof Arrayable ? $value->toArray() : $value;
    }, $this->items);
}
    
answered by 04.05.2016 / 15:27
source