本文整理汇总了PHP中Agent::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Agent::get方法的具体用法?PHP Agent::get怎么用?PHP Agent::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAgent
public function getAgent()
{
$agent = Agent::get(['id' => $this->agent_id]);
return $agent ? $agent[0] : null;
}
示例2: login
public function login()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// check user type
if ($_POST['usertype'] === 'owner') {
// if owner
$owner = Owner::get(['email' => $_POST['email']])[0];
if ($owner) {
// check the password
if (validate_password($_POST['password'], $owner->password)) {
// password matched
$_SESSION['usertype'] = USERTYPE_OWNER;
$_SESSION['user'] = $owner;
} else {
// wrong password
Flash::set('error_message', 'Wrong email or password');
}
} else {
// cannot find the user with the email
Flash::set('error_message', 'Wrong email or password');
}
} elseif ($_POST['usertype'] === 'tenant') {
$tenant = Tenant::get(['email' => $_POST['email']])[0];
if ($tenant) {
// check the password
if (validate_password($_POST['password'], $tenant->password)) {
// password matched
$_SESSION['usertype'] = USERTYPE_TENANT;
$_SESSION['user'] = $tenant;
} else {
// wrong password
Flash::set('error_message', 'Wrong email or password');
}
} else {
// cannot find the user with the email
Flash::set('error_message', 'Wrong email or password');
}
} elseif ($_POST['usertype'] === 'agent') {
$agent = Agent::get(['email' => $_POST['email']])[0];
if ($agent) {
// check the password
if (validate_password($_POST['password'], $agent->password)) {
// password matched
$_SESSION['usertype'] = USERTYPE_AGENT;
$_SESSION['user'] = $agent;
} else {
// wrong password
Flash::set('error_message', 'Wrong email or password');
}
} else {
// cannot find the user with the email
Flash::set('error_message', 'Wrong email or password');
}
} elseif ($_POST['usertype'] === 'real_estate') {
// if real estate
$realestate = Real_Estate::get(['name' => $_POST['name']])[0];
if ($realestate) {
// check password
if (validate_password($_POST['password'], $realestate->password)) {
$_SESSION['usertype'] = USERTYPE_REALESTATE;
$_SESSION['user'] = $realestate;
} else {
// wrong password
Flash::set('error_message', 'Wrong password');
}
}
}
}
$this->redirect('/');
}