/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit(Request $request, $id) { $concerts = Concert::orderBy('created_at', 'asc')->get(); $currentConcert = Concert::where('id', $id)->first(); $artists = Artist::orderBy('created_at', 'asc')->get(); $lieux = array(); foreach ($concerts as $concert) { if (!in_array($concert->lieu, $lieux)) { $lieux[] = $concert->lieu; } } return view('admin_edit', ['lieux' => $lieux, 'artists' => $artists, 'currentConcert' => $currentConcert]); }
public function concert(Request $request, $concertId) { $concert = Concert::where('id', $concertId)->first(); $imagePath = "assets/images/" . $concert->artist->image; $client = new Google_Client(); $client->setDeveloperKey("AIzaSyD0HX0kSeMKR_QWBYx-HE-6Wui9zL66ePU"); $youtube = new Google_Service_YouTube($client); $searchResponse = $youtube->search->listSearch('id,snippet', array('q' => $concert->artist->name, 'type' => 'video', 'maxResults' => 1)); foreach ($searchResponse['items'] as $searchResult) { switch ($searchResult['id']['kind']) { case 'youtube#video': $youtubeVideoId = $searchResult['id']['videoId']; break; } } return view('concert', ['imagePath' => $imagePath, 'concert' => $concert, 'videoUrl' => "http://www.youtube.com/embed/" . $youtubeVideoId]); }