本文整理汇总了PHP中StudentInfo::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP StudentInfo::findOrFail方法的具体用法?PHP StudentInfo::findOrFail怎么用?PHP StudentInfo::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StudentInfo
的用法示例。
在下文中一共展示了StudentInfo::findOrFail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: anySearch
/**
* Open Job Search
*
* @param string $catId
*/
public function anySearch($catId = null)
{
$categories = array();
if (Input::has("q") && trim(Input::get("q")) != "") {
$q = strtolower(Input::get("q"));
$foundCategories = JobCategory::whereRaw("LOWER(keywords) LIKE '%{$q}%' OR Lower(name) LIKE '%{$q}%'")->lists("id");
$categories = array_merge($categories, $foundCategories);
} else {
if (Input::has("catId") && intval(Input::get("catId")) > 0) {
$catId = intval(Input::get("catId"));
$categories[] = $catId;
}
}
$user = Sentry::getUser();
$student = StudentInfo::findOrFail($user->id);
$studentAddress = $student->primaryAddress;
if ($studentAddress == null) {
$studentAddress = $student->primaryAddress;
}
// $categories=$student->studentJobPreferences->lists("id");
$orWhereQ = array();
if (count($categories) > 0) {
$orWhereQ[] = '`jobs`.`job_category_id` IN (' . implode(",", $categories) . ')';
}
if (isset($q)) {
$subWhereTitle = array();
$subWhereDescript = array();
if (strpos($q, ' ') > 0) {
foreach (explode(' ', $q) as $r) {
$subWhereTitle[] = "LOWER(`jobs`.`job_title`) LIKE '%" . $r . "%'";
$subWhereDescript[] = "LOWER(`jobs`.`job_description`) LIKE '%" . $r . "%'";
}
$orWhereQ[] = "(" . implode(" AND ", $subWhereTitle) . ")";
$orWhereQ[] = "(" . implode(" AND ", $subWhereDescript) . ")";
} else {
$orWhereQ[] = "LOWER(`jobs`.`job_title`) LIKE '%" . $q . "%'";
$orWhereQ[] = "LOWER(`jobs`.`job_description`) LIKE '%" . $q . "%'";
}
}
if (count($orWhereQ) > 0) {
$jobs = Job::whereJobStatusId(JobStatus::$OPEN)->where("jobs.start_date", ">=", date("Y-m-d"))->whereRaw('(' . implode(" OR ", $orWhereQ) . ")")->select("jobs.*", Address::distanceSelectStatement($studentAddress->latitude, $studentAddress->longitude, 'distance', 'jobs'))->orderBy('jobs.start_date', 'asc')->having("distance", "<=", $student->studentProfile->preferred_job_radius)->get();
} else {
$jobs = Job::whereJobStatusId(JobStatus::$OPEN)->where("jobs.start_date", ">=", date("Y-m-d"))->select("jobs.*", Address::distanceSelectStatement($studentAddress->latitude, $studentAddress->longitude, 'distance', 'jobs'))->orderBy('jobs.start_date', 'asc')->having("distance", "<=", $student->studentProfile->preferred_job_radius)->get();
}
$student->load('userCertifications');
return View::make("jobs.search", compact("jobs", "student"));
}