【发布时间】:2021-04-20 04:47:58
【问题描述】:
我已经对这个错误进行了一些谷歌搜索,我发现 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: -
它有效,谢谢!
-
@brombeer - 发表您的评论作为答案/解决方案。
-
@JohnHanley 正要吃,必须先喂猫! ;) 谢谢