/** * Display a listing of the resource. * * @return Response */ public function index() { try { $response = ['multimedia' => []]; $statusCode = 200; $multimedia = Multimedia::all(); //$users = User::all()->take(9); foreach ($multimedia as $m) { $user = User::find($m->user_id); $festival = Festival::find($m->user_id); $response['multimedia'][] = ['id' => $m->id, 'festival' => $festival['name'] . ': ' . $festival['start_datetime'] . '-' . $festival['end_datetime'] . '[' . $festival['city'] . ']', 'file_type' => $m->file_type, 'filename' => $m->filename, 'user' => $user['name'] . ", " . $user['full_name'], 'created_at' => $m->created_at]; } } catch (Exception $e) { $statusCode = 404; } finally { return Response::json($response['multimedia'], $statusCode); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Festival::find($id)->Person()->detach(); Festival::find($id)->Guest()->detach(); Festival::find($id)->Performer()->detach(); Festival::find($id)->Association()->detach(); Festival::find($id)->User()->detach(); $festival = Festival::find($id); $f = Festival::where('id', $id)->delete(); $response = []; $response["name"] = $festival->name; if ($f->trashed()) { $statusCode = 200; $response['result'] = "deleted"; } else { $statusCode = 422; $response['result'] = "Cannot delete."; } return Response::json($response, $statusCode); }