generated from creasico/laravel-package
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(api): init rest api for all available resources
Signed-off-by: Fery Wardiyanto <[email protected]>
- Loading branch information
1 parent
f30f649
commit e443985
Showing
13 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Creasi\Nusa\Http\Controllers\DistrictController; | ||
use Creasi\Nusa\Http\Controllers\ProvinceController; | ||
use Creasi\Nusa\Http\Controllers\RegencyController; | ||
use Creasi\Nusa\Http\Controllers\VillageController; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
Route::name('nusa.')->group(function () { | ||
Route::controller(ProvinceController::class)->prefix('provinces')->group(function () { | ||
Route::get('/', 'index')->name('provinces.index'); | ||
Route::get('/{province}', 'show')->name('provinces.show'); | ||
Route::get('/{province}/regencies', 'regencies')->name('provinces.regencies'); | ||
Route::get('/{province}/districts', 'districts')->name('provinces.districts'); | ||
Route::get('/{province}/villages', 'villages')->name('provinces.villages'); | ||
}); | ||
|
||
Route::controller(RegencyController::class)->prefix('regencies')->group(function () { | ||
Route::get('/', 'index')->name('regencies.index'); | ||
Route::get('/{regency}', 'show')->name('regencies.show'); | ||
Route::get('/{regency}/districts', 'districts')->name('regencies.districts'); | ||
Route::get('/{regency}/villages', 'villages')->name('regencies.villages'); | ||
}); | ||
|
||
Route::controller(DistrictController::class)->prefix('districts')->group(function () { | ||
Route::get('/', 'index')->name('districts.index'); | ||
Route::get('/{district}', 'show')->name('districts.show'); | ||
Route::get('/{district}/villages', 'villages')->name('districts.villages'); | ||
}); | ||
|
||
Route::controller(VillageController::class)->prefix('villages')->group(function () { | ||
Route::get('/', 'index')->name('villages.index'); | ||
Route::get('/{village}', 'show')->name('villages.show'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Controllers; | ||
|
||
use Creasi\Nusa\Contracts\District; | ||
use Creasi\Nusa\Http\Resources\NusaResource; | ||
|
||
class DistrictController | ||
{ | ||
public function index() | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function show() | ||
{ | ||
return new NusaResource([]); | ||
} | ||
|
||
public function villages(District $district) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Controllers; | ||
|
||
use Creasi\Nusa\Contracts\Province; | ||
use Creasi\Nusa\Http\Resources\NusaResource; | ||
|
||
class ProvinceController | ||
{ | ||
public function index() | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function show() | ||
{ | ||
return new NusaResource([]); | ||
} | ||
|
||
public function regencies(Province $province) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function districts(Province $province) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function villages(Province $province) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Controllers; | ||
|
||
use Creasi\Nusa\Contracts\Regency; | ||
use Creasi\Nusa\Http\Resources\NusaResource; | ||
|
||
class RegencyController | ||
{ | ||
public function index() | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function show() | ||
{ | ||
return new NusaResource([]); | ||
} | ||
|
||
public function districts(Regency $regency) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function villages(Regency $regency) | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Controllers; | ||
|
||
use Creasi\Nusa\Http\Resources\NusaResource; | ||
|
||
class VillageController | ||
{ | ||
public function index() | ||
{ | ||
return NusaResource::collection([]); | ||
} | ||
|
||
public function show() | ||
{ | ||
return new NusaResource([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class NusaRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'search' => ['nullable', 'string'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Creasi\Nusa\Http\Resources; | ||
|
||
use Creasi\Nusa\Models\Model; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
/** | ||
* @property-read Model $resource | ||
*/ | ||
class NusaResource extends JsonResource | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Creasi\Tests\Features; | ||
|
||
use Creasi\Tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
#[Group('api')] | ||
class DistrictsTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_should_be_true() | ||
{ | ||
$response = $this->getJson('nusa/districts'); | ||
|
||
$response->assertOk(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Creasi\Tests\Features; | ||
|
||
use Creasi\Tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
#[Group('api')] | ||
class ProvincesTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_should_be_true() | ||
{ | ||
$response = $this->getJson('nusa/provinces'); | ||
|
||
$response->assertOk(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Creasi\Tests\Features; | ||
|
||
use Creasi\Tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
#[Group('api')] | ||
class RegenciesTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_should_be_true() | ||
{ | ||
$response = $this->getJson('nusa/regencies'); | ||
|
||
$response->assertOk(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Creasi\Tests\Features; | ||
|
||
use Creasi\Tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
#[Group('api')] | ||
class VillagesTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_should_be_true() | ||
{ | ||
$response = $this->getJson('nusa/villages'); | ||
|
||
$response->assertOk(); | ||
} | ||
} |