app/Http/Controllers/Admin/UserController.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, $id)
    {
        $rule=[
            'name'=>'required|string|min:2|max:255',
            'last_name'=>'required|string|min:2|max:255',
            'email'=>'required|string|min:11|max:255'
        ];
        $this->validate($request, $rule);
        $user=User::findOrFail($id);
        $user->name=$request->get('name');
        $user->last_name=$request->get('last_name');
        $user->email=$request->get('email');
        $user->type=$request->has('type') ? 1 : 0;
        if(!$user->isClean()){
            $user->save();
        }
        return redirect()->route('index-user',$id);
    }
public function update ( Request $ request , $ id ) { $ rule = [ 'name' => 'required|string|min:2|max:255' , 'last_name' => 'required|string|min:2|max:255' , 'email' => 'required|string|min:11|max:255' ] ; $ this -> validate ( $ request , $ rule ) ; $ user = User :: findOrFail ( $ id ) ; $ user -> name = $ request -> get ( 'name' ) ; $ user -> last_name = $ request -> get ( 'last_name' ) ; $ user -> email = $ request -> get ( 'email' ) ; $ user -> type = $ request -> has ( 'type' ) ? 1 : 0 ; if ( ! $ user -> isClean ( ) ) { $ user -> save ( ) ; } return redirect ( ) -> route ( 'index-user' , $ id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .