本文整理汇总了PHP中Result::success方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::success方法的具体用法?PHP Result::success怎么用?PHP Result::success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result::success方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!$this->stopOnFail) {
return $this->taskExec($this->getCommand())->run();
}
foreach ($this->exec as $command) {
$result = $this->taskExec($command)->run();
if (!$result->wasSuccessful()) {
return $result;
}
}
return Result::success($this);
}
示例2: elseif
$agents = $request->param('logAgents');
$result = Logs::updateLog($id, $logData, $agents);
if ($result > 0) {
$response->json(Result::success('Log Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Log not Updated.'));
} else {
$response->json(Result::error('Log not found'));
}
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$logData = Logs::getLog($id);
$agents = Agents::getLogAgents($id);
$notes = Notes::getLogNotes($id);
$result = array("logData" => $logData, "logAgents" => $agents, "logNotes" => $notes);
if ($logData) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Log not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Logs::deleteLog($id);
if ($result > 0) {
$response->json(Result::success('Log Deleted.'));
} else {
$response->json(Result::error('Log not Deleted'));
}
});
示例3: session_id
$result = User::login($request->param('username', 'none'), $request->param('password', 'none'), $request->param('rememberMe', true));
if ($result === true) {
$response->json(Result::success('logged in successfully', ['REMEMBERMECOOKIE' => $_SESSION['REMEMBERMECOOKIE'], 'SESSIONID' => session_id()]));
} else {
$response->json(Result::error($result));
}
});
//$this->respond(['GET','POST'], '/register', function ($request, $response, $service) {
// $result = User::register($request->param('userName','none'),$request->param('mail','none'),
// $request->param('password','none'),$request->param('passwordRepeat','none'));
// if ($result != -1) {
// $response->json(Result::success('registered successfuly',['id'=>$result]));
// }
// else
// $response->json(Result::error($result));
//});
$this->respond(['GET', 'POST'], '/logout', function ($request, $response, $service) {
if (User::isLoggedIn() !== true) {
$response->json(Result::error('Can\'t Logout: Not logged in.'));
} else {
User::logout();
$response->json(Result::success('Logged out successfully'));
}
});
$this->respond(['GET', 'POST'], '/isLoggedIn', function ($request, $response, $service) {
if (User::isLoggedIn() !== true) {
$response->json(Result::error('You"re not logged in', [false]));
} else {
$response->json(Result::success('You"re logged in', array('userId' => User::currentUserID())));
}
});
示例4: function
<?php
$this->respond(['GET', 'POST'], '/get/crm', function ($request, $response, $service, $app) {
$investors = Investors::getInvestorsForControlPanel();
$result = array("investors" => $investors);
$response->json(Result::success('', $result));
});
示例5: function
<?php
$this->respond(['GET', 'POST'], '/uploadFile', function ($request, $response, $service, $app) {
$ans = FileUploader::uploadFile();
if ($ans != -1) {
$response->json(Result::success('file uploaded.', ['path' => $ans]));
} else {
$response->json(Result::error('file upload Failed.'));
}
});
示例6: json_decode
$data = json_decode($request->body(), true);
// Access only for Current Agent
if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
$response->json(Result::error('Access is denied'));
} else {
$result = Agents::updateAgent($id, $data);
if ($result > 0) {
$response->json(Result::success('Agent Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Agent not Updated.'));
} else {
$response->json(Result::error('Agent not found'));
}
}
});
$this->respond(['GET', 'POST'], '/edit/password/[:id]', function ($request, $response, $service) {
$id = $request->param('id');
$oldPassword = $request->param('oldPassword', '');
$newPassword = $request->param('newPassword', '');
// Access only for Current Agent
if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
$response->json(Result::error('Access is denied'));
} else {
$result = User::editPassword($oldPassword, $newPassword, $newPassword);
if ($result === true) {
$response->json(Result::success('edited password successfully'));
} else {
$response->json(Result::error($result));
}
}
});
示例7: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Demands::getDemand($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Demand not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = Demands::updateDemand($id, $data);
if ($result > 0) {
$response->json(Result::success('Demand Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Demand not Updated.'));
} else {
$response->json(Result::error('Demand not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Demands::deleteDemand($id);
if ($result > 0) {
$response->json(Result::success('Demand Deleted.'));
} else {
$response->json(Result::error('Demand not Deleted'));
}
});
示例8: function
$id = $request->param('id');
$result = Conversations::getConversation($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Conversation not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body(), true);
$oldConv = Conversations::getConversation($id);
Logs::createLogOnConversationSave($data, $oldConv);
$result = Conversations::updateConversation($id, $data);
if ($result > 0) {
$response->json(Result::success('Conversation Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Conversation not Updated.'));
} else {
$response->json(Result::error('Conversation not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Conversations::deleteConversation($id);
if ($result > 0) {
$response->json(Result::success('Conversation Deleted.'));
} else {
$response->json(Result::error('Conversation not Deleted'));
}
});
示例9: function
} else {
$response->json(Result::error('Contact not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$contactResult = Contacts::deleteContact($id);
Conversations::deleteContactConversations($id);
if ($contactResult > 0) {
$response->json(Result::success('Contact Deleted.'));
} else {
$response->json(Result::error('Contact not Deleted'));
}
});
$this->respond(['GET', 'POST'], '/get/all-for-index', function ($request, $response, $service, $app) {
$result = Contacts::getAllContactsForIndex();
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
$result = Contacts::getAllContacts();
$response->json(Result::success('', $result));
});
$this->respond(['GET', 'POST'], '/get-investor-contacts/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$contacts = Contacts::getInvestorCrmContacts($id);
if ($contacts) {
$response->json(Result::success('', $contacts));
} else {
$response->json(Result::error('Contact not found'));
}
});
示例10: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Notes::getNote($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('Note not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = Notes::updateNote($id, $data);
if ($result > 0) {
$response->json(Result::success('Note Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('Note not Updated.'));
} else {
$response->json(Result::error('Note not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = Notes::deleteNote($id);
if ($result > 0) {
$response->json(Result::success('Note Deleted.'));
} else {
$response->json(Result::error('Note not Deleted'));
}
});
示例11: _try
/**
* Tries to execute the given function and returns a result representing the
* outcome, i.e. if the function returns normally, a successful result is
* returned containing the return value and if the function throws an exception,
* an error result is returned containing the error
*
* $f should take no arguments and return a value that will be wrapped in a
* success if the computation completes successfully
*
* The _ is required if we want to use the word try since it is keyword
*/
public static function _try(callable $f)
{
try {
return Result::success($f());
} catch (\Exception $error) {
return Result::error($error);
}
}
示例12: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = RentAreas::getRentArea($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('RentArea not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = RentAreas::updateRentArea($id, $data);
if ($result > 0) {
$response->json(Result::success('RentArea Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('RentArea not Updated.'));
} else {
$response->json(Result::error('RentArea not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = RentAreas::deleteRentArea($id);
if ($result > 0) {
$response->json(Result::success('RentArea Deleted.'));
} else {
$response->json(Result::error('RentArea not Deleted'));
}
});
示例13: function
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = TrackedAssets::getTrackedAsset($id);
if ($result) {
$response->json(Result::success('', $result));
} else {
$response->json(Result::error('TrackedAsset not found'));
}
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$data = json_decode($request->body());
$result = TrackedAssets::updateTrackedAsset($id, $data);
if ($result > 0) {
$response->json(Result::success('TrackedAsset Updated.'));
} elseif ($result === 0) {
$response->json(Result::success('TrackedAsset not Updated.'));
} else {
$response->json(Result::error('TrackedAsset not found'));
}
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
$id = $request->param('id');
$result = TrackedAssets::deleteTrackedAsset($id);
if ($result > 0) {
$response->json(Result::success('TrackedAsset Deleted.'));
} else {
$response->json(Result::error('TrackedAsset not Deleted'));
}
});