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.
Installation
Section titled “Installation”1. Install via Composer
Section titled “1. Install via Composer”composer require yahaaylabs/laravel-barangay-search2. Set Your API Key
Section titled “2. Set Your API Key”Add your GIS.PH API key to your .env file:
GISPH_API_KEY=your_api_key_hereGet your API key from https://gis.ph
Basic Usage
Section titled “Basic Usage”<livewire:barangay-search wire:model="selectedBarangay" label="Select Barangay" placeholder="Search for a barangay..."/>With Form Integration
Section titled “With Form Integration”<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>Component Props
Section titled “Component Props”| Prop | Type | Default | Description |
|---|---|---|---|
wire:model | mixed | null | Bind the selected barangay |
label | string | '' | Label text above the input |
placeholder | string | Config value | Placeholder text for the input |
required | boolean | false | Mark field as required |
clearable | boolean | true | Show clear button |
hint | string | '' | Helper text below the input |
municipalityCode | string | null | Filter results by municipality code |
cityCode | string | null | Filter results by city code |
provinceCode | string | null | Filter results by province code |
containerClass | string | '' | Additional CSS classes for container |
inputClass | string | '' | Additional CSS classes for input |
Response Format
Section titled “Response Format”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',]