Lecturize / Laravel-Addresses

Simple address and contact management for Laravel.
MIT License
197 stars 39 forks source link

Custom attributes in the Address table #15

Closed ryanrapini closed 3 years ago

ryanrapini commented 6 years ago

Is there a way to add custom attributes to the Address table? In the past I thought I was able to do so but it seems if I add anything else now in the attributes list, it is stored as NULL.

$address = $request->user()->addAddress([
            'full_name'    => $request->full_name,   // NULL
            'company'      => $request->company,  // NULL
            'street'       => $request->street,
            'street_extra' => $request->street_extra,
            'city'         => $request->city,
            'state'        => $request->state,
            'country_id'   => 840, // US Country Code
            'post_code'    => $request->post_code,
            'phone'        => $request->phone,     // NULL
            'is_shipping'  => $request->is_shipping, 
            'is_billing'   => $request->is_billing,
        ]);
AlexanderPoellmann commented 6 years ago

That might be due to the fact, that those custom attributes are not in the models fillable array. You would need to create your own model and extending the package's Address model. I was planning to add that "custom_model" feature anyway soon, but feel free to open a pull request.

ryanrapini commented 6 years ago

PR sent, feel free to change my variable names and/or critique my code, i'm a newbie to Laravel dev.