public function getAssociation($asso = null) { try { $response = []; $statusCode = 200; //$city = City::all(); $id = null; if (!is_numeric($asso)) { $asso = Association::where('name', 'like', '%' . $asso . '%'); } else { $id = Request::segment(2); } if ($id != null) { $asso = Association::where('country_id', 'like', $this->getCountryIdOfFestival($id)); } $asso = $asso->get(); foreach ($asso as $a) { $response[] = ['id' => $a->id, 'name' => $a->name . ' (' . $a->address . ')']; } } catch (Exception $e) { $statusCode = 404; } finally { return Response::json($response, $statusCode); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Association::find($id)->Festival()->detach(); Association::find($id)->Person()->detach(); $ass = Association::find($id); $a = Association::where('id', $id)->delete(); $response = []; $response["name"] = $ass->name; if ($a > trashed()) { $statusCode = 200; $response['result'] = "deleted"; } else { $statusCode = 422; $response['result'] = "Cannot delete."; } return Response::json($response, $statusCode); }