我有这个错误,它说控制器does not exist
我的路线
use App\Http\Controllers\PasienController;
Route::resource('/pasien', PasienController::class)->only(['index']);
该控制器
<?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());
}
}
}
我尝试从API获取数据并返回数据
2条答案
按热度按时间nkoocmlb1#
更新您的路线以遵循laravel 5.6的正确格式
tct7dpnv2#
在你的路由中,把你的控制器放在一个括号[]里,就像这样Route::resource('/pasien',[PasienController::class])-〉only('index');