user_address.php 936 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class UserAddress extends Model {
  3. protected static $table = "user_address";
  4. protected static $id_field = "id";
  5. protected static $fillable_fields = ["user_id", "name", "address_1", "address_2", "city", "county", "postal_code", "state", "country", "latitude", "longitude", "max_radius_miles"];
  6. protected static $field_map = [
  7. ];
  8. const RADIUSES = [
  9. "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",
  10. ];
  11. // Object methods
  12. public function getUser() {
  13. return User::get($this->user_id);
  14. }
  15. public function getDisplayAddress() {
  16. $parts = [];
  17. $fields = ["address_1", "address_2", "city", "county", "postal_code", "state", "country"];
  18. foreach($fields as $field) {
  19. $parts[] = $this->$field;
  20. }
  21. return implode(", ", array_filter($parts));
  22. }
  23. public function getGeolocation() {
  24. return [$this->latitude, $this->longitude];
  25. }
  26. }
  27. ?>