/** * Display a listing of the resource. * * @return Response */ public function index() { try { $response = ['association' => []]; $statusCode = 200; $data = Association::all(); //$users = User::all()->take(9); foreach ($data as $d) { $response['association'][] = ['id' => $d->id, 'name' => $d->name, 'address' => $d->start_datetime, 'city' => $d->end_datetime, 'country' => $d->Country()->country_name, 'created_at' => $d->created_at, 'updated_at' => $d->updated_at, 'deleted_at' => $d->deleted_at]; } } catch (Exception $e) { $statusCode = 404; } finally { return Response::json($response['association'], $statusCode); } }