$episodes]); }); Route::get('/detail/{id}', function(int $id) { $ep = Episode::find($id); $title = $ep->title; $subtitles = $ep->subtitles; $mediacomposition = json_decode($ep->mediacomposition, 1); $durationSteps = $mediacomposition['chapterList'][0]['duration'] / 1000 / 10; $subdata = json_decode($ep->subtitle_data, 1); $subdata_senti = json_decode($ep->sentiments_from_sub, 1); $subdata_senti['data'] = ""; $subdata_senti['weights'] = ""; foreach ($subdata_senti['sentiments'] as $value) { $subdata_senti['data'] .= $value[0].","; $subdata_senti['weights'] .= (30 * $value[1]).","; } $wordsPerMinute = array_slice($subdata['word_count'], -1)[0] / (($mediacomposition['chapterList'][0]['duration'] / 1000) / 60); $parser = new Podlove\Webvtt\Parser(); $subtitles = $parser->parse($subtitles); return view('detail', ['title' => $title, 'subtitles' => $subtitles, 'mediacomposition' => $mediacomposition, 'durationSteps' => $durationSteps, 'dom_color' => $ep->viz_data, 'subdata' => $subdata, 'senti_subdata' => $subdata_senti, 'wpm' => $wordsPerMinute]); });