app/Http/Controllers/dashboard/admin/RolesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Roles $role)
    {
        $this->rules['id'] = [Rule::unique('roles')->ignore($role->id)];
        $request->validate($this->rules);
        try {
            if (!$role->update(["name" => $request->post('name'), "id" => $request->post('id')])) throw new Error('Cannot update');
            return $this->status('success', 'success updated role');
        } catch (\Exception $error) {
            return $this->status('error', $error->getMessage());
        }
    }
public function update ( Request $ request , Roles $ role ) { $ this -> rules [ 'id' ] = [ Rule :: unique ( 'roles' ) -> ignore ( $ role -> id ) ] ; $ request -> validate ( $ this -> rules ) ; try { if ( ! $ role -> update ( [ " name " => $ request -> post ( 'name' ) , " id " => $ request -> post ( 'id' ) ] ) ) throw new Error ( 'Cannot update' ) ; return $ this -> status ( 'success' , 'success updated role' ) ; } catch ( \ Exception $ error ) { return $ this -> status ( 'error' , $ error -> getMessage ( ) ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .