app/Http/Controllers/ContentController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $currentData = Storage::get('saveFile.json');
        $arrayData = json_decode($currentData, true);
        $extra = $array = array(
            'title' => $_POST['title'],
            'text' => $_POST['text'], 
            'image'=>$_POST['image'],
            'author'=>$_POST['author']
        );
        $arrayData[] = $extra;
        $finalData = json_encode($arrayData);
        if(Storage::put('saveFile.json',$finalData)){
            echo 'success';
            return redirect('/');
        }
    }
public function store ( Request $ request ) { $ currentData = Storage :: get ( 'saveFile.json' ) ; $ arrayData = json_decode ( $ currentData , true ) ; $ extra = $ array = array ( 'title' => $ _POST [ 'title' ] , 'text' => $ _POST [ 'text' ] , 'image' => $ _POST [ 'image' ] , 'author' => $ _POST [ 'author' ] ) ; $ arrayData [ ] = $ extra ; $ finalData = json_encode ( $ arrayData ) ; if ( Storage :: put ( 'saveFile.json' , $ finalData ) ) { echo 'success' ; return redirect ( '/' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
// file_put_contents('saveFile.json',json_encode($data));