app/Http/Controllers/dashboard/admin/UsersController.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, User $user)
    {
        if ($this->protectSuperUser($user->role_id)) return $this->status('error', 'access denied');
        $this->rules['username'] = ['required', Rule::unique('users')->ignore($user->id)];
        $this->rules['email'] =  ['email:dns', " required", Rule::unique('users')->ignore($user->id)];
        $request->validate($this->rules);
        $data = [
            "username" => $request->post('username'),
            "email" => $request->post('email'),
        ];
        $response = $user->update($data);
        if (!$response) return $this->status();
        return $this->status('success', "success update users");
    }
public function update ( Request $ request , User $ user ) { if ( $ this -> protectSuperUser ( $ user -> role_id ) ) return $ this -> status ( 'error' , 'access denied' ) ; $ this -> rules [ 'username' ] = [ 'required' , Rule :: unique ( 'users' ) -> ignore ( $ user -> id ) ] ; $ this -> rules [ 'email' ] = [ 'email:dns' , "  required " , Rule :: unique ( 'users' ) -> ignore ( $ user -> id ) ] ; $ request -> validate ( $ this -> rules ) ; $ data = [ " username " => $ request -> post ( 'username' ) , " email " => $ request -> post ( 'email' ) , ] ; $ response = $ user -> update ( $ data ) ; if ( ! $ response ) return $ this -> status ( ) ; return $ this -> status ( 'success' , " success update users " ) ; }
Update the specified resource in storage.
Update the specified resource in storage .