app/Http/Controllers/ContentController.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)
    {
        $data = Storage::disk('local')->get('saveFile.json');
        $json = json_decode($data,true);
        $title = $request->title;
        $author = $request->author;
        $content = $request->text;
        $image = $request->image;
        $json[$id]=array(
                'title'=> $title,
                'author'=> $author,
                'text' => $content,
                'image' => $image,
            );
        Storage::disk('local')->put('saveFile.json', json_encode($json, JSON_PRETTY_PRINT));
        return redirect('/')->with('berhasil','Data Berhasil di Ubah');
    }
public function update ( Request $ request , $ id ) { $ data = Storage :: disk ( 'local' ) -> get ( 'saveFile.json' ) ; $ json = json_decode ( $ data , true ) ; $ title = $ request -> title ; $ author = $ request -> author ; $ content = $ request -> text ; $ image = $ request -> image ; $ json [ $ id ] = array ( 'title' => $ title , 'author' => $ author , 'text' => $ content , 'image' => $ image , ) ; Storage :: disk ( 'local' ) -> put ( 'saveFile.json' , json_encode ( $ json , JSON_PRETTY_PRINT ) ) ; return redirect ( '/' ) -> with ( 'berhasil' , 'Data Berhasil di Ubah' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// $data = file_get_contents('storage/data.json'); // $update = $request->only(['judul', 'author', 'content']);