app/Http/Controllers/Admin/MyProfileController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, User $myprofile)
    {
        $validator = Validator::make($request->all(), [
            'email'         => ['required', 'string', 'email', 'max:255'],
            'fname'         => ['required', 'string', 'max:255'],
            'lname'         => ['required', 'string', 'max:255'],
            'password'      => ['required', 'string', 'min:8', 'confirmed'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('admin.myprofile.index');
        }
        $data = $request->all();
        $myprofile->email = $data['email'];
        $myprofile->fname = $data['fname'];
        $myprofile->lname = $data['lname'];
        $myprofile->password = Hash::make($data['password']);
        if(!$myprofile->save()) {
            $request->session()->flash('error', 'There is an error modifying your account information!');
            return redirect()->route('admin.myprofile.index');
        }
        $request->session()->flash('success', 'You have modified your account information!');
        return redirect()->route('admin.myprofile.index');
    }
public function update ( Request $ request , User $ myprofile ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'email' => [ 'required' , 'string' , 'email' , 'max:255' ] , 'fname' => [ 'required' , 'string' , 'max:255' ] , 'lname' => [ 'required' , 'string' , 'max:255' ] , 'password' => [ 'required' , 'string' , 'min:8' , 'confirmed' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'admin.myprofile.index' ) ; } $ data = $ request -> all ( ) ; $ myprofile -> email = $ data [ 'email' ] ; $ myprofile -> fname = $ data [ 'fname' ] ; $ myprofile -> lname = $ data [ 'lname' ] ; $ myprofile -> password = Hash :: make ( $ data [ 'password' ] ) ; if ( ! $ myprofile -> save ( ) ) { $ request -> session ( ) -> flash ( 'error' , 'There is an error modifying your account information!' ) ; return redirect ( ) -> route ( 'admin.myprofile.index' ) ; } $ request -> session ( ) -> flash ( 'success' , 'You have modified your account information!' ) ; return redirect ( ) -> route ( 'admin.myprofile.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .