本文整理汇总了PHP中Institution::whereHas方法的典型用法代码示例。如果您正苦于以下问题:PHP Institution::whereHas方法的具体用法?PHP Institution::whereHas怎么用?PHP Institution::whereHas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Institution
的用法示例。
在下文中一共展示了Institution::whereHas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPostPage
public function getPostPage()
{
$obj = new BaseController();
$campusid = $this->getDevice();
if ($campusid == 0) {
$countryname = $obj->getCountryName();
if ($countryname == 'NONE') {
return Redirect::route('selectcampus-get');
} else {
//check whether the country name exists inthe db
$locationcountry = Country::where('name', '=', $countryname);
if ($locationcountry->count()) {
$locationcountrycode = $locationcountry->first()->code;
$locationcountrycode = strtolower($locationcountrycode);
return Redirect::route('selectcountryid', $locationcountrycode);
} else {
return Redirect::route('selectcampus-get');
}
}
}
$college = Institution::whereHas('Branch', function ($query) use($campusid) {
$query->where('id', '=', $campusid);
})->first();
View::share('college', $college);
$mycampus = Branch::where('id', '=', $campusid)->first();
View::share('mycampus', $mycampus);
if (Auth::user()) {
return View::make('member.post');
}
return View::make('guest.post');
}
示例2: getMoreHomePageSqueeb
public function getMoreHomePageSqueeb($lastid)
{
$campusid = $this->getDevice();
$obj = new BaseController();
$campusid = $this->getDevice();
if ($campusid == 0) {
$countryname = $obj->getCountryName();
if ($countryname == 'NONE') {
return Redirect::route('selectcampus-get');
} else {
//check whether the country name exists inthe db
$locationcountry = Country::where('name', '=', $countryname);
if ($locationcountry->count()) {
$locationcountrycode = $locationcountry->first()->code;
$locationcountrycode = strtolower($locationcountrycode);
return Redirect::route('selectcountryid', $locationcountrycode);
} else {
return Redirect::route('selectcampus-get');
}
}
}
$more = true;
$college = Institution::whereHas('Branch', function ($query) use($campusid) {
$query->where('id', '=', $campusid);
})->first();
$collegeid = $college->id;
$countryid = Country::where('id', '=', $college->country_id)->first()->id;
//get the top squeeb to display
$newsqueebs = Squeeb::where('active', '=', TRUE)->where('branch_id', '=', $campusid)->orderBy('id', 'DESC')->take(self::TOP_SQUEEB_LIMIT)->get();
View::share('newsqueebs', $newsqueebs);
$squeebs = Notice::whereHas('Squeeb', function ($query) use($campusid, $lastid) {
$query->where('branch_id', '=', $campusid)->where('id', '<', $lastid)->where('active', '=', TRUE);
})->orwhereHas('Squeeb', function ($query) use($lastid) {
$query->where('branch_id', '=', 0)->where('world', '=', TRUE)->where('id', '<', $lastid)->where('active', '=', TRUE);
})->orwhereHas('Squeeb', function ($query) use($lastid, $countryid) {
$query->where('branch_id', '=', 0)->where('country', '=', $countryid)->where('id', '<', $lastid)->where('active', '=', TRUE);
})->orwhereHas('Squeeb', function ($query) use($lastid, $collegeid) {
$query->where('branch_id', '=', 0)->where('college', '=', $collegeid)->where('id', '<', $lastid)->where('active', '=', TRUE);
});
$last = $squeebs;
$squeebs = $squeebs->orderBy('id', 'DESC')->take(self::SQUEEB_LIMIT)->get();
if ($squeebs->count()) {
$last_id = $last->orderBy('id', 'DESC')->take(self::SQUEEB_LIMIT)->get()->last()->Squeeb()->first()->id;
}
View::share('last_id', $last_id);
View::share('squeebs', $squeebs);
//get the top squeeb to display
$topsqueebs = Squeeb::where('active', '=', TRUE)->where('model', '=', 'Notice')->where('branch_id', '=', $campusid)->orderBy('views', 'DESC')->take(self::TOP_SQUEEB_LIMIT)->get();
View::share('topsqueebs', $topsqueebs);
if ($lastid <= 0 or $squeebs->count() != self::SQUEEB_LIMIT) {
$more = false;
}
$college = Institution::whereHas('Branch', function ($query) use($campusid) {
$query->where('id', '=', $campusid);
})->first();
View::share('college', $college);
View::share('more', $more);
$mycampus = Branch::where('id', '=', $campusid)->first();
View::share('mycampus', $mycampus);
return View::make('guest.home');
}