aifaiz / myrstates
Laravel 5.* Library for Malaysian states list
1.0.3
2019-08-10 09:37 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: 6.*
This package is auto-updated.
Last update: 2026-03-11 00:50:16 UTC
README
This package is useful for people who would want to create dropdown input or anything that requires the Malaysian States list.
Installing
$ composer require aifaiz/myrstates
How to use
you can use it in anywhere such as controller. declare the namespace like this before the class
use AiFaiz\Malaysia\MyStates;
accessing the states:
$states = MyStates::getStates()
Collections of states will be returned and you can perform collection method on it. such as:
$states->first()
refer to Collection Methods for more info on utilizing collections
Getting the state name by code
$state = MyStates::stateByCode('KUL')
// Kuala Lumpur
Using Alias
You can use it directly in laravel blade template like this:
<select>
@foreach(MalayStates::getStates() as $state)
<option value="{{$state['code']}}">{{$state['name']}}</option>
@endforeach
</select>
