本文整理汇总了PHP中JsonResponse::successful方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonResponse::successful方法的具体用法?PHP JsonResponse::successful怎么用?PHP JsonResponse::successful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonResponse
的用法示例。
在下文中一共展示了JsonResponse::successful方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PasswordService
<?php
require_once "../services/PasswordService.php";
require_once "../assets/php/JsonResponse.php";
$service = new PasswordService();
$response = new JsonResponse();
if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "add") {
$record = $service->Create($_POST["password"]);
$html = getRow($record);
$response->successful("Successfully added a new password", $record, $html);
} else {
if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "delete") {
$record = $service->Delete($_POST['id']);
$response->successful("Successfully deleted a password", $record);
} else {
if (isset($_POST) && isset($_POST['action']) && $_POST["action"] == "edit") {
$record = $service->Update($_POST["password"]);
$html = getRow($record);
$response->successful("Successfully updated the password", $record, $html);
} else {
if (isset($_POST) && isset($_POST['id'])) {
$record = $service->Get($_POST['id']);
$response->successful("Successfully retrieved the password", $record);
} else {
$records = $service->Get();
$html = "<table style='margin-bottom: 0;' class='table table-condensed table-bordered table-hover'><thead><tr>";
$html .= "<th>Place</th>";
$html .= "<th>Username</th>";
$html .= "<th>Password</th>";
$html .= "</tr></thead><tbody>";
for ($i = 0; $i < count($records); $i++) {
示例2: function
});
$app->get("/thankyou/", function () use($app) {
$app->render("template.php", array("view" => "thankyou.html"));
});
$app->get("/thankyou2/", function () use($app) {
$app->render("template.php", array("view" => "thankyou2.html"));
});
$app->get("/events/pokerrun/", function () use($app) {
$app->render("template.php", array("view" => "pokerrun.html"));
});
$app->post("/pokerrun/", function () use($app) {
$data = $_POST["data"];
$response = new JsonResponse();
$response->successful("Successfully created a new request for poker run.", $data);
});
$app->post("/contact/", function () use($app) {
$response = new JsonResponse();
$contact = new Contact();
$result = $contact->sendContactEmail($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['message']);
if (result) {
$response->successful("Message successfully sent. Thank you for contacting Waterfowlers for Warriors.", $result);
} else {
$response->unsuccessful("Failed to send message. Please try again later.", $result);
}
});
$app->post('/profile/', function () use($app) {
$profile = new Profile();
$profile->saveProfile($_POST);
$app->render("template.php", array("view" => "thankyou2.html"));
});
$app->run();
示例3: Plinq
$pitems = new Plinq($itemsrev);
$items1 = $pitems->Where(function ($key, $value) {
return $key % 2 != 0;
})->ToArray();
$items2 = $pitems->Where(function ($key, $value) {
return $key % 2 == 0;
})->ToArray();
foreach ($items1 as $item) {
$html1 .= $app->view()->fetch("item.php", ["model" => $item]);
}
foreach ($items2 as $item) {
$html2 .= $app->view()->fetch("item.php", ["model" => $item]);
}
$app->render('template.php', array('view' => "home.php", 'state' => $state, 'items1' => $html1, 'items2' => $html2));
});
$app->post('/add/', function () use($app) {
$response = new JsonResponse();
$itemService = new ItemService();
$model = $itemService->insert($_POST, $_FILES["images"]);
$modelWithImages = $itemService->getWithImages($model->id);
$html = $app->view()->fetch("item.php", ["model" => $modelWithImages]);
$response->successful("Successfully added a new post", $modelWithImages, $html);
});
$app->post("/delete/", function () use($app) {
$response = new JsonResponse();
$itemService = new ItemService();
$id = $_POST["id"];
$result = $itemService->delete($id);
$response->successful("Successfully deleted the post", $result);
});
$app->run();