app/Http/Controllers/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)
    {
        $user = User::find($id);
        $role = $user->getRoleNames();
        $user->name = $request->nama;
        $user->save();
        $kasir = Kasir::where('user_id', Auth::id())->first();
        if ($kasir) {
            $kasir->umur = $request->umur;
            $kasir->alamat = $request->alamat;
            $kasir->save();
        }
        if ($role[0] == 'kasir') {
            $kasir = new Kasir();
            $kasir->user_id = $user->id;
            $kasir->umur = $request->umur;
            $kasir->alamat = $request->alamat;
            $kasir->save();
        }
        return redirect()->route('akun.index')->with('info', 'Data user berhasil diupdate');
    }
public function update ( Request $ request , $ id ) { $ user = User :: find ( $ id ) ; $ role = $ user -> getRoleNames ( ) ; $ user -> name = $ request -> nama ; $ user -> save ( ) ; $ kasir = Kasir :: where ( 'user_id' , Auth :: id ( ) ) -> first ( ) ; if ( $ kasir ) { $ kasir -> umur = $ request -> umur ; $ kasir -> alamat = $ request -> alamat ; $ kasir -> save ( ) ; } if ( $ role [ 0 ] == 'kasir' ) { $ kasir = new Kasir ( ) ; $ kasir -> user_id = $ user -> id ; $ kasir -> umur = $ request -> umur ; $ kasir -> alamat = $ request -> alamat ; $ kasir -> save ( ) ; } return redirect ( ) -> route ( 'akun.index' ) -> with ( 'info' , 'Data user berhasil diupdate' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .