SymfonyComponentDebugExceptionFatalThrowableError syntax error, unexpected ‘:’, expecting ‘)’

I have done some googling on this error I have an it seems to be an error in the EmployeeController but I cannot see what I have done that is different to my other templates that work. This is the error message

SymfonyComponentDebugExceptionFatalThrowableError

syntax error,unexpected ‘:’, expecting ‘)’

This is my [email protected]

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
        ]);
    }

Can someone help me to find the fault?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

status: and message: in your ->jsRespond(...) calls are causing the error. Remove them from the calls:

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
        ]);
    }


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x