I have this error where it said that the controller does not exist
My routes
use App\Http\Controllers\PasienController;
Route::resource('/pasien', PasienController::class)->only(['index']);
The controller
<?php
namespace App\Http\Controllers;
use App\Token;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;
use RealRashid\SweetAlert\Facades\Alert;
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
CodePudding user response:
Route::post('/pasien', 'PasienController@index');
Update your route to follow the right format for laravel 5.6
CodePudding user response:
In your route rap your controller in a bracket [], like this Route::resource('/pasien', [PasienController::class])->only('index');