Added the ability to edit and delete posts which includes uploading of images for the posts and managing those images
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Vendored
+40
-5
@@ -53,7 +53,7 @@ class timelineRoutes implements routesInterface
|
||||
$app->patch("/timelineData/{timeline}/{id}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
if ($args["timeline"] == "edu" && $args["id"] != "undefined")
|
||||
if ($args["timeline"] == "edu" && $args["id"] != null)
|
||||
{
|
||||
if (empty($data["dateFrom"]) || empty($data["dateTo"]) || empty($data["grade"]) || empty($data["course"]))
|
||||
{
|
||||
@@ -61,8 +61,16 @@ class timelineRoutes implements routesInterface
|
||||
$response->getBody()->write(json_encode(array("error" => "Only some of the data was sent")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
$message = $this->timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"]);
|
||||
|
||||
if (!$this->timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"]))
|
||||
if ($message == "not found")
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Edu data with ID " . $args["id"] . " was not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message == "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
@@ -82,7 +90,16 @@ class timelineRoutes implements routesInterface
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$this->timelineData->updateWorkData($data["dateFrom"], $data["dateTo"], $data["companyName"], $data["area"], $data["title"], $args["id"]))
|
||||
$message = $this->timelineData->updateWorkData($data["dateFrom"], $data["dateTo"], $data["companyName"], $data["area"], $data["title"], $args["id"]);
|
||||
|
||||
if ($message == "not found")
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Work data with ID " . $args["id"] . " was not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message == "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
@@ -101,7 +118,16 @@ class timelineRoutes implements routesInterface
|
||||
{
|
||||
if ($args["timeline"] == "edu" && $args["id"] != null)
|
||||
{
|
||||
if (!$this->timelineData->deleteEduData($args["id"]))
|
||||
$message = $this->timelineData->deleteEduData($args["id"]);
|
||||
|
||||
if ($message == "not found")
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Edu data with ID " . $args["id"] . " was not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message == "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
@@ -113,7 +139,16 @@ class timelineRoutes implements routesInterface
|
||||
|
||||
if ($args["timeline"] == "work" && $args["id"] != null)
|
||||
{
|
||||
if (!$this->timelineData->deleteWorkData($args["id"]))
|
||||
$message = $this->timelineData->deleteWorkData($args["id"]);
|
||||
|
||||
if ($message == "not found")
|
||||
{
|
||||
// uh oh sent some empty data
|
||||
$response->getBody()->write(json_encode(array("error" => "Work data with ID " . $args["id"] . " was not found")));
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
|
||||
if ($message == "error")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
|
||||
Reference in New Issue
Block a user