Original Arrays
Use raw() when a v1 consumer needs the original payload, including spellings, keys, category labels, and order. The accessor is available on the standalone service and the Laravel facade. Each view accepts the same optional language parameter as the typed API.
The five views
Method on RawData | Shape | Original file |
|---|---|---|
all() | Province name -> district name -> classification label -> list of local level names | src/Datas/allData.php |
provinces() | List of province names | src/Datas/provinces.php |
districts() | List of district names | src/Datas/districts.php |
provincesWithDistricts() | Province name -> list of district names | src/Datas/provincesWithDistricts.php |
districtsWithLocalBodies() | District name -> classification label -> list of local level names | src/Datas/districtsWithLocalBodies.php |
The leaf values are plain PHP strings. Empty groups remain empty arrays. The raw methods do not return records or query objects, do not attach package IDs, and do not combine the two languages.
Read a branch of the hierarchy
use KodeFarmers\NepalData\Language;
$raw = $data->raw();
$englishHierarchy = $raw->all();
$ruralNames = $englishHierarchy['Koshi']['Taplejung']['Ga.Pa.'];
$nepaliDistrictNames = $raw->districts(Language::NEPALI);
$nepaliGroups = $raw->districtsWithLocalBodies(Language::NEPALI)['ताप्लेजुङ'];
An English Ga.Pa. group is the corresponding गा.पा. classification in the Nepali view. Refer to the classification table for all four labels. When accessing nested arrays by an input value, check the key is present (for example, with ?? []) or use the typed queries’ parent filters.
These views preserve differences in the original source. For instance, raw()->provinces() uses Madesh while raw()->all() uses Madhesh as the province key. Do not assume you can use an arbitrary value from one view as a key in another. See Data Sources and Limitations for a comparison, or Upgrading from v1 for migration examples.