jeudi 23 août 2018

Work with foreach in Laravel: delete same values

I found way to delete duplicate values in the result but it doesn't work correctly. How to fix it?

I have next code:

    public function getListPositionByApplication($app_id){
    // $app_id = \Request::input('app_id');
    $list = SparePartApplicationPositionProvider::where('app_id',$app_id)->with(['provider','application_position'])->orderBy('apos_id')
            ->get();
            $aa=0;
            foreach ($list as $value) {
                if($value->apos_id==$aa){
                    $value->application_position->name_detail='----';
                }
                $aa = $value->apos_id;
                 Log::info($value->apos_id);
            }

    return $list;
}

Log::info give next information: 26,26,26,26,26,26,27,27,27,27,27,27,28 but $value->application_position->name_detail have '----' in all cases with the exception of last value



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LoODxj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire