本文整理汇总了PHP中Guardian::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Guardian::save方法的具体用法?PHP Guardian::save怎么用?PHP Guardian::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guardian
的用法示例。
在下文中一共展示了Guardian::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addGuardian
/**
* @before _secure, _school
*/
public function addGuardian($scholar_user_id)
{
$usr = \User::first(array("id = ?" => $scholar_user_id), array("id"));
if (!$usr) {
self::redirect("/school");
}
$this->setSEO(array("title" => "Parent Info | Student | School"));
$view = $this->getActionView();
if (RequestMethods::post("action") == "saveParent") {
$opts = array();
$opts["name"] = RequestMethods::post("name");
$opts["email"] = RequestMethods::post("email");
$opts["phone"] = RequestMethods::post("phone");
try {
$user = $this->_createUser($opts);
$loc = new Location(array("address" => RequestMethods::post("address"), "city" => RequestMethods::post("city"), "latitude" => "", "longitude" => "", "user_id" => $user->id));
$loc->save();
$guardian = new Guardian(array("user_id" => $user->id, "scholar_user_id" => $scholar_user_id, "relation" => RequestMethods::post("relation"), "occupation" => RequestMethods::post("occupation"), "qualification" => RequestMethods::post("qualification"), "location_id" => $loc->id));
$guardian->save();
$view->set("success", $guardian->relation . " info saved successfully!!");
} catch (\Exception $e) {
$view->set("error", true);
$view->set("message", $e->getMessage());
}
}
}