first(); $client = Client::where('id', $note->client_id)->first(); return view('client/note', compact('note', 'client')); } public function selectSectionTemplateForm($note_uid, Request $request) { $sectionTemplates = SectionTemplate::all(); $note = Note::where('uid', $note_uid)->first(); return view('client/select_section_template_form', compact('note', 'sectionTemplates')); } public function sectionCreateForm($note_uid, $section_template_uid, Request $request) { $note = Note::where('uid', $note_uid)->first(); $sectionTemplate = SectionTemplate::where('uid', $section_template_uid)->first(); $section = null; // convenience include(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php')); } public function processFormSubmit(Request $request) { // for CREATE $note_uid = $request->note_uid; $section_template_uid = $request->section_template_uid; // for UPDATE $section_uid = $request->section_uid; $section = $section_uid ? Section::where('uid', $section_uid)->first() : null; $note = null; $sectionTemplate = null; if($section == null){ $note = Note::where('uid', $note_uid)->first(); $sectionTemplate = SectionTemplate::where('uid', $section_template_uid)->first(); } else { $note = $section->note(); $sectionTemplate = $section->sectionTemplate(); } $newContentData = []; // we wish to pass THESE arguments into this include: // if CREATE, $note and $sectionTemplate, and $request // if UPDATE, $section, and $request include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php')); $newContentData = ['dog' => 'bark', 'cat' => 'meow']; // now, create summaryHtml appropriate ob_start(); echo 'this is not going to scream anywhere.'; include(storage_path('sections/' . $sectionTemplate->internal_name . '/summary.php')); $newSummaryHtml = ob_get_contents(); ob_end_clean(); if($section){ // call Java to update section }else{ // call Java to create section $data = [ 'noteUid' => $note->uid, 'sectionTemplateUid' => $sectionTemplate->uid, 'contentData' => json_encode($newContentData), 'summaryHtml' => $newSummaryHtml ]; $url = env('BACKEND_URL', 'http://localhost:8080') . '/api/section/create'; $response = Http::asForm() ->withHeaders(['sessionKey'=>$request->cookie('sessionKey')]) ->post($url, $data) ->json(); dd($response); } } }