Symfony\Component\Debug\Exception\FatalThrowableError 语法错误,意外的“:”,应为“)”
Symfony\Component\Debug\Exception\FatalThrowableError syntax error, unexpected ':', expecting ')'
我已经对这个错误进行了一些谷歌搜索,我发现它似乎是 EmployeeController 中的一个错误,但我看不到我所做的与我的其他工作模板不同的地方。这是错误信息
Symfony\Component\Debug\Exception\FatalThrowableError
syntax error,unexpected ':', expecting ')'
这是我的 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
]);
}
我已经对这个错误进行了一些谷歌搜索,我发现它似乎是 EmployeeController 中的一个错误,但我看不到我所做的与我的其他工作模板不同的地方。这是错误信息
Symfony\Component\Debug\Exception\FatalThrowableError
syntax error,unexpected ':', expecting ')'
这是我的 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
]);
}