- php 8.1
- laravel 10
- You can install the package via composer:
composer install
- Create .env and generate key:
cp .env.example .env
php artisan key:generate
- Open .env add the following line:
'roa_url' => env('RAJAONGKIR_API_URL'),
'roa_key' => env('RAJAONGKIR_API_KEY'),
'roa_src' => (bool) env('RAJAONGKIR_SOURCE', false),
-
Integrasi dengan API province & city Rajaongkir (paket starter), Online link for testing :
-
Artisan command for fetching API data province & city Rajaongkir Perform database migration with command
php artisan migrate
and running command
php artisan app:sync-rajaongkir-data
- REST API for province & city search
- Test using Talent Api Tester or Postman: [GET] https://onlinetests.pronext.id/public/search/provinces?id={province_id}
- Test using Talent Api Tester or Postman: [GET] https://onlinetests.pronext.id/public/search/cities?id={city_id}
-
Search data source for provinces & cities can be through database or direct Rajaongkir API (swapable implementation):
- Test using Talent Api Tester or Postman: [GET] https://onlinetests.pronext.id/public/search/provinces?id={province_id}
- Test using Talent Api Tester or Postman: [GET] https://onlinetests.pronext.id/public/search/cities?id={city_id}
-
Login API so that the search endpoint can only be accessed by authorized users Use Laravel Tinker to run Factory to Create Dummy Data
php artisan tinker
and running command
\App\Models\User::factory()->count(3)->create();
- Test using Talent Api Tester or Postman: [POST] https://onlinetests.pronext.id/public/api/login?email={email}&password={password}
- Use login token for Authorization on [GET] https://onlinetests.pronext.id/public/search/provinces?id={province_id} and [GET] https://onlinetests.pronext.id/public/search/cities?id={city_id}
If there are problems trying to log in as a user, try creating a passport token. running command
php artisan passport:install
Then try the API Login user again
- Unit test / API test agar web service tetap reliable & maintainable
- Use command
php artisan make:test ProvinceCityApiTest
for unit test the province & cities search api. - Use comand
php artisan make:test UserLoginApiTest
for unit test the User Auth unit test api
- Use command