Lecturize / Laravel-Addresses

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

How to overide code to add city from external table #2

Closed hassansaqib closed 7 years ago

hassansaqib commented 8 years ago

Hi Alexander, I am using your package but I have a little need to override the code. I am looking to make a separate table for cities in which I will have only id and city name. I want to have only city_id in your logic. What is the best way to do it? I do not want to change in vendor folders to avoid problems in future.

I will highly appreciate your suggestions..

AlexanderPoellmann commented 7 years ago

Mhm, well you could store the id in the city column, extend the Address model and add an attribute like so:

public function getCityAttribute
{
    return City::find($this->city)->name;
}