I am trying to post form input data into JSON file stored in storage/app/data.json
use Illuminate\Http\Request;
class ContactController extends Controller
{
function index() {
return view('contact_form');
}
function store(Request $request) {
try {
// my data storage location is project_root/storage/app/data.json file.
$contactInfo = Storage::disk('local')->exists('data.json') ? json_decode(Storage::disk('local')->get('data.json')) : [];
$inputData = $request->only(['name', 'email', 'message','subject']);
$inputData['datetime_submitted'] = date('Y-m-d H:i:s');
array_push($contactInfo,$inputData);
Storage::disk('local')->put('data.json', json_encode($contactInfo));
return $inputData;
} catch(Exception $e) {
return ['error' => true, 'message' => $e->getMessage()];
}
}
}
route
Route::get('/sss', 'ContactController@index');
Route::post('/contact/store', 'ContactController@store');
when I start the server it returns with this err
(FatalThrowableError class'App\http\controllers\storage' not found)
I can see that it's looking in the app folder
how can I make it return to the storage folder instead of the app folder?
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2TtfFYI
via IFTTT
Aucun commentaire:
Enregistrer un commentaire