app/Http/Controllers/IntroduceController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\GioiThieu  $gioiThieu
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $get_data = GioiThieu::all();
        $data = GioiThieu::find($id);
        $data->noiDung = $request->input('noiDung');
        $trangThai=0;
        if($request->has('trangThai')){
            foreach ($get_data as $get){
                if($get->trangThai==1){
                    $get->trangThai=0;
                    $get->save();
                }
            }
            $trangThai=$request->input('trangThai');
        }
        $data->trangThai=$trangThai;
        $data->save();
        return redirect()->route('admin.introduce.index');
    }
public function update ( Request $ request , $ id ) { $ get_data = GioiThieu :: all ( ) ; $ data = GioiThieu :: find ( $ id ) ; $ data -> noiDung = $ request -> input ( 'noiDung' ) ; $ trangThai = 0 ; if ( $ request -> has ( 'trangThai' ) ) { foreach ( $ get_data as $ get ) { if ( $ get -> trangThai == 1 ) { $ get -> trangThai = 0 ; $ get -> save ( ) ; } } $ trangThai = $ request -> input ( 'trangThai' ) ; } $ data -> trangThai = $ trangThai ; $ data -> save ( ) ; return redirect ( ) -> route ( 'admin.introduce.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .