location.php 812 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class Location extends Model {
  3. protected static $table = "location";
  4. protected static $id_field = "id";
  5. protected static $fillable_fields = ["customer_id", "name", "address_1", "address_2", "city", "county", "postal_code", "state", "country", "shop_left", "shop_right", "latitude", "longitude", "dts_verified"];
  6. protected static $field_map = [
  7. ];
  8. // Object methods
  9. public function getCustomer() {
  10. return Customer::get($this->customer_id);
  11. }
  12. public function getDisplayAddress($fields = ["address_1", "address_2", "city", "county", "postal_code", "state", "country"]) {
  13. $parts = [];
  14. foreach($fields as $field) {
  15. $parts[] = $this->$field;
  16. }
  17. return implode(", ", array_filter($parts));
  18. }
  19. public function getGeolocation() {
  20. return [$this->latitude, $this->longitude];
  21. }
  22. }
  23. ?>