我已经对此错误进行了一些谷歌搜索。我在EmployeeController中发现了一个错误,但我看不出我所做的与其他可用模板不同的事情。这是错误消息
Symfony\Component\Debug\Exception\FatalThrowableError
语法错误,意外的":",应为"(">
这是我的EmployeeController@edit
public function edit($id, $jabatan)
{
// gabisa pake findOrFail karena ajax
// return response()->json($employees);
$employees = Employee::find($id);
if ($employees) {
if ((int) $jabatan == 0) {
$jabatan = Sallary::select(['id', 'nama_jabatan'])->get()->toArray();
} else $jabatan = [];
return $this->jsRespond(status: true, message: 'Berhasil ambil', [
'employee' => $employees->toArray(),
'jabatan' => $jabatan
]);
} else {
return $this->jsRespond(status: false, message: 'Data Gagal Diambil');
}
}
private function jsRespond($status, $message, $others = [])
{
return response()->json([
'status' => $status,
'message' => $message,
'others' => $others
]);
}
有人能帮我找出毛病吗?
->jsRespond(...)
调用中的status:
和message:
导致错误。从通话中删除它们:
public function edit($id, $jabatan)
{
// gabisa pake findOrFail karena ajax
// return response()->json($employees);
$employees = Employee::find($id);
if ($employees) {
if ((int) $jabatan == 0) {
$jabatan = Sallary::select(['id', 'nama_jabatan'])->get()->toArray();
} else $jabatan = [];
return $this->jsRespond(true, 'Berhasil ambil', [
'employee' => $employees->toArray(),
'jabatan' => $jabatan
]);
} else {
return $this->jsRespond(false, 'Data Gagal Diambil');
}
}
private function jsRespond($status, $message, $others = [])
{
return response()->json([
'status' => $status,
'message' => $message,
'others' => $others
]);
}