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)
    {
        $request->validate([
            'first_name' => ['required', 'string', 'max:255'],
            'last_name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255'],
            'phone_number' => ['required', 'string'],
            'password' => ['nullable']
        ],[
            'user_type.required' => 'فیلد نقش کاربر الزامی است'
        ]);
        $admin = User::findOrFail($id);
        $admin->first_name = $request->input('first_name');
        $admin->last_name  = $request->input('last_name');
        $admin->email      = $request->input('email');
        $admin->phone_number      = $request->input('phone_number');
        if ($request->input('password') != '') {
            $admin->password = \Hash::make($request->input('password'));
        }
        $admin->save();
        return redirect()->route('admin.user.index');
    }
public function update ( Request $ request , $ id ) { $ request -> validate ( [ 'first_name' => [ 'required' , 'string' , 'max:255' ] , 'last_name' => [ 'required' , 'string' , 'max:255' ] , 'email' => [ 'required' , 'string' , 'email' , 'max:255' ] , 'phone_number' => [ 'required' , 'string' ] , 'password' => [ 'nullable' ] ] , [ 'user_type.required' => 'فیلد نقش کاربر الزامی است' ] ) ; $ admin = User :: findOrFail ( $ id ) ; $ admin -> first_name = $ request -> input ( 'first_name' ) ; $ admin -> last_name = $ request -> input ( 'last_name' ) ; $ admin -> email = $ request -> input ( 'email' ) ; $ admin -> phone_number = $ request -> input ( 'phone_number' ) ; if ( $ request -> input ( 'password' ) != '' ) { $ admin -> password = \ Hash :: make ( $ request -> input ( 'password' ) ) ; } $ admin -> save ( ) ; return redirect ( ) -> route ( 'admin.user.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//validate input data //find admin and initialize //save admin