Laravel in my Multiple Attribute functionality is not proper working it can’t increase the array size

  Uncategorised

Please tell me the error when I add multi attribute (array) of member it take only first of arrray[0] and does not increases index number Please tell in where I problem in this code. Does anyone know the problem here:

It is controller code functionality manage_members_list:

public function manage_members_list($id=”){

    if ($id > 0) {
        $arr = Members_list::where(['id' => $id])->get();
        $result['id'] = $arr[0]->id;
        $result['name'] = $arr['0']->name;
        $result['father_name'] = $arr['0']->father_name;
        $result['email'] = $arr['0']->email;
        $result['mobile'] = $arr['0']->mobile;
        $result['phone'] = $arr['0']->phone;
        $result['cnic'] = $arr['0']->cnic;
        $result['city'] = $arr['0']->city;
        $result['area'] = $arr['0']->area;
        $result["member_gruntee"] = Garuanter::where(['member_id' => $id])->get();

    } else {
        $result['name'] = '';
        $result['father_name'] = '';
        $result['email'] = '';
        $result['mobile'] = '';
        $result['phone'] = '';
        $result['cnic'] = '';
        $result['id'] = 0;
        $result['city'] = '';
        $result['area'] = '';

        $result['member_gruntee'][0]['id'] = 0;
        $result['member_gruntee'][0]['gname'] = '';
        $result['member_gruntee'][0]['gaddress'] = '';
        $result['member_gruntee'][0]['gcnic'] = '';
        $result['member_gruntee'][0]['gphone'] = '';

 
    }
    $result['city_list'] = City::all();
    return view('manage_members_list', $result);
}

if you understand this problem then ok, otherwise I’ll send you more code

Source: Laravel 5 Questions

Leave a Reply