Skip to content

Laravel Barangay Search

A Laravel Livewire component for searching Philippine Barangays with optional Mary UI support. This package uses the GIS.PH SDK to interact with the official GIS.PH API.

Terminal window
composer require yahaaylabs/laravel-barangay-search

Add your GIS.PH API key to your .env file:

GISPH_API_KEY=your_api_key_here

Get your API key from https://gis.ph

<livewire:barangay-search
wire:model="selectedBarangay"
label="Select Barangay"
placeholder="Search for a barangay..."
/>
<x-form wire:submit="save">
<x-input label="Name" wire:model="name" />
<livewire:barangay-search
wire:model="form.barangay"
label="Barangay"
:required="true"
hint="Start typing to search"
/>
<x-slot:actions>
<x-button label="Cancel" link="/dashboard" />
<x-button label="Save" type="submit" spinner="save" />
</x-slot:actions>
</x-form>
PropTypeDefaultDescription
wire:modelmixednullBind the selected barangay
labelstring''Label text above the input
placeholderstringConfig valuePlaceholder text for the input
requiredbooleanfalseMark field as required
clearablebooleantrueShow clear button
hintstring''Helper text below the input
municipalityCodestringnullFilter results by municipality code
cityCodestringnullFilter results by city code
provinceCodestringnullFilter results by province code
containerClassstring''Additional CSS classes for container
inputClassstring''Additional CSS classes for input

When a barangay is selected, the component returns an array with the following structure:

[
'code' => '012345678',
'name' => 'Barangay Name',
'municipality' => 'Municipality Name',
'municipality_code' => '012345',
'city' => 'City Name', // nullable
'city_code' => '012345', // nullable
'province' => 'Province Name',
'province_code' => '0123',
'region' => 'Region Name',
'region_code' => '01',
'full_address' => 'Barangay Name, Municipality Name, Province Name',
]