jeudi 5 novembre 2020

How to get value json in laravel

JSON : {"faktor":["sds"],"presentase":["23"]}

Laravel Controller : public static function factor_task($id_project, $urutan) {

   return (DB::table('project_faktor')  ->select('faktor_presentase')
                                        ->where('id_project', '=', $id_project)
                                        ->where('urutan', '=', $urutan)
                                        ->get());
}

Blade View:

$id_project = $projects->id_project;
$array_delay_factors = (json_decode(App\Http\Controllers\ProjectController::factor_task('51', '1'),true));
$array_delay_factors_count = $array_delay_factors[0]['faktor_presentase'];
              
echo ($array_delay_factors_count->faktor);

But, it shows error like this Trying to get property 'faktor' of non-object (0) enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire