mercredi 11 juillet 2018

Laravel htmlentities() expects parameter 1 to be string, array given after it's converted to string

Trying to set and get session in laravel. In my controller I'm converting an array to string which doesn't throw an error if printed, however froim the error looks like session is getting an array instead of a string. Controller:

 public function  getQuestions(){

    $questions = DB::table('questions')->orderBy(DB::raw('RAND()'))->get();

    $questions= json_decode(json_encode($questions), true);

    Session::put('questions', $questions);

    return view('test', array('questions' => $questions));
}

Blade:



An error:

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire