| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- class UserAddress extends Model {
- protected static $table = "user_address";
- protected static $id_field = "id";
- protected static $fillable_fields = ["user_id", "name", "address_1", "address_2", "city", "county", "postal_code", "state", "country", "latitude", "longitude", "max_radius_miles"];
- protected static $field_map = [
- ];
- const RADIUSES = [
- "0.25", "0.50", "1.00", "1.50", "2.00", "2.50", "3.00", "4.00", "5.00", "7.50", "10.00", "12.50", "15.00", "20.00", "25.00",
- ];
- // Object methods
- public function getUser() {
- return User::get($this->user_id);
- }
- public function getDisplayAddress() {
- $parts = [];
- $fields = ["address_1", "address_2", "city", "county", "postal_code", "state", "country"];
- foreach($fields as $field) {
- $parts[] = $this->$field;
- }
- return implode(", ", array_filter($parts));
- }
- public function getGeolocation() {
- return [$this->latitude, $this->longitude];
- }
- }
- ?>
|