app/Http/Controllers/AdminUsersController.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(UsersEditRequest $request, $id)
    {
        $user = User::findOrFail($id);
        if(trim($request->password) == ''){
            $input = $request->except('password');
        } else {
            $input = $request->all();
            $input['password'] = bcrypt($request->password);
        }
        if($file = $request->file('photo_id')){
            $name = time() . $file->getClientOriginalName();
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['photo_id'] = $photo->id;
        }
        $user->update($input);
        Session::flash('updated_user', 'The user has been updated');
        return redirect('admin/users/');
    }
public function update ( UsersEditRequest $ request , $ id ) { $ user = User :: findOrFail ( $ id ) ; if ( trim ( $ request -> password ) == '' ) { $ input = $ request -> except ( 'password' ) ; } else { $ input = $ request -> all ( ) ; $ input [ 'password' ] = bcrypt ( $ request -> password ) ; } if ( $ file = $ request -> file ( 'photo_id' ) ) { $ name = time ( ) . $ file -> getClientOriginalName ( ) ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'photo_id' ] = $ photo -> id ; } $ user -> update ( $ input ) ; Session :: flash ( 'updated_user' , 'The user has been updated' ) ; return redirect ( 'admin/users/' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// /*
        $input = $request->all();

        if($file = $request->file('photo_id')){

            $name = time() . $file->getClientOriginalName();
            $photo = Photo::create(['file' => $name ]);

            $file->move('images', $name);

            $input['photo_id'] = $photo->id;
            
        }

        $input['password'] = bcrypt($request->password);
        User::create($input);

        return redirect('/admin/users');
        */