app/Http/Controllers/Admin/ApproverController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\Models\Department $department
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Department $department)
    {
        $this->validater($request);
        $department->department_id = $request->department_id;
        $department->reim_department_id = $request->reim_department_id;
        DB::beginTransaction();
        $department->save();
        $department->approver1()->delete();
        $department->approver2()->delete();
        $department->approver3()->delete();
        $this->saveApprovers($request, $department);
        DB::commit();
        app('Approver')->approverUserToCache();
        $department->load(['approver1', 'approver2', 'approver3']);
        return response($department, 201);
    }
public function update ( Request $ request , Department $ department ) { $ this -> validater ( $ request ) ; $ department -> department_id = $ request -> department_id ; $ department -> reim_department_id = $ request -> reim_department_id ; DB :: beginTransaction ( ) ; $ department -> save ( ) ; $ department -> approver1 ( ) -> delete ( ) ; $ department -> approver2 ( ) -> delete ( ) ; $ department -> approver3 ( ) -> delete ( ) ; $ this -> saveApprovers ( $ request , $ department ) ; DB :: commit ( ) ; app ( 'Approver' ) -> approverUserToCache ( ) ; $ department -> load ( [ 'approver1' , 'approver2' , 'approver3' ] ) ; return response ( $ department , 201 ) ; }
Update the specified resource in storage.
Update the specified resource in storage .