cheesegrits / filament-google-maps

Google Maps package for Filament PHP
234 stars 65 forks source link

Added latLng Attributes functionality to Geocomplete #56

Open eugenpasca opened 12 months ago

eugenpasca commented 12 months ago

This PR introduces an enhancement that allows users to effectively override the model's getLatLngAttributes() method. This improvement caters to scenarios where a form or model contains multiple Geocomplete fields, each of which requires conversion to distinct latitude and longitude fields.

Key Features:

  1. Ability to define separate latitude and longitude fields for each Geocomplete input.
  2. Provides flexibility to structure and manage multiple Geocomplete fields within a single model or form.

Example Code Snippet

  RogGeocomplete::make('from_address')
      ->live()
      ->columnSpanFull()
      ->updateLatLng()
      ->latLngAttributes([
          'lat' => 'from_lat',
          'lng' => 'from_lng',
      ]),
  TextInput::make('from_lat'),
  TextInput::make('from_lng'),

  RogGeocomplete::make('to_address')
      ->live()
      ->columnSpanFull()
      ->updateLatLng()
      ->latLngAttributes([
          'lat' => 'to_lat',
          'lng' => 'to_lng',
      ]),
  TextInput::make('to_lat'),
  TextInput::make('to_lng'),
cheesegrits commented 11 months ago

@eugenpasca can you update the README to document / give an example of this, then I'll merge it.

cheesegrits commented 7 months ago

@eugenpasca any chance you can respond to my previous msg?

abishekrsrikaanth commented 5 months ago

Would love for this to be merged if the functionality works.

eugenpasca commented 5 months ago

Hello, sorry for not responding to this. @cheesegrits , I will take care of the documentation this week so you can merge it.