mercredi 28 novembre 2018

Trying to get property' of non-object, update existing users with new forms

I have extended an existing form, with another form with address information. New clients i can edit, since they got the values which are given with them.

Existing users, who dont have address information yet, i can't edit.

Trying to get property 'region' of non-object

I think this is because, the edit page returns a Null value.

    $regions = DB::table("regions")->pluck("name","id");
    $address = Address::where('id', $request->address_id)->with('region')->first();
    $data = $this->data->getEditClient($id);
    $admins = $this->data->getAdmin();

 if (is_null($address) && is_null($regions))
    {
        return view('client.edit', [

    //code for succesfully go to the edit page without address information.

        ]);
    } 


    return view('client.edit', [
        'client'        => $data, 
        'admins'        => $admins,
        'regions'       => $regions,
        'address'       => $address
        ]);
    }
}

Anyone knows the right solution for this error?

Greetings,

Aucun commentaire:

Enregistrer un commentaire