I have this error where it said that the controller does not exist
My routes
use AppHttpControllersPasienController;
Route::resource('/pasien', PasienController::class)->only(['index']);
The controller
<?php
namespace AppHttpControllers;
use AppToken;
use IlluminateHttpRequest;
use IlluminateSupportFacadesHttp;
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesValidator;
use RealRashidSweetAlertFacadesAlert;
class PasienController extends Controller
{
public function index(Request $request)
{
$patient = null;
if (isset($request->nik)) {
$response = $this->patient_by_nik($request->nik);
$data = $response->getData();
if ($response->status() == 200) {
if ($data->total) {
$patient = $data->entry[0]->resource;
Alert::success($response->statusText(), 'Pasien Ditemukan');
} else {
Alert::error('Not Found', 'Pasien Tidak Ditemukan');
}
} else {
Alert::error($response->statusText() . ' ' . $response->status());
}
}
}
I was trying to get data from an API and return the data
2
Answers
In your route wrap your controller class in a bracket
[]
, like this:Route::resource('/pasien', [PasienController::class])->only('index');
Update your route to follow the right format for laravel 5.6