本文整理匯總了PHP中app\Page::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page::select方法的具體用法?PHP Page::select怎麽用?PHP Page::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Page
的用法示例。
在下文中一共展示了Page::select方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
/**
* Register custom Validator
*/
Validator::extend('require_one_of_array', function ($attribute, $value, $parameters, $validator) {
if (!is_array($value)) {
return false;
}
foreach ($value as $k => $v) {
if (!empty($v)) {
return true;
}
}
return false;
});
/**
* Get Admin Menu from DB
*/
view()->composer('admin.layout.admin_index_layout', function ($view) {
$adminMenu = new AdminMenu();
$view->with('adminMenu', $adminMenu->getMenu());
$controller = Util::getController();
$view->with('controller', $controller);
$view->with('controller_parent_id', $adminMenu->getParent($controller));
});
/**
* Get Settings From DB
*/
$settings = Cache::rememberForever('settings', function () {
return Settings::all();
});
if (!$settings->isEmpty()) {
foreach ($settings as $k => $v) {
config(['dc.' . $v->setting_name => $v->setting_value]);
}
}
/**
* Get Custom Pages From DB, Get Central Banner
*/
view()->composer('layout.index_layout', function ($view) {
//header menu
$headerMenu = Cache::rememberForever('headerMenu', function () {
return Page::select('page_title', 'page_slug')->where('page_position', Page::HEADER_MENU)->where('page_active', 1)->orderBy('page_ord', 'ASC')->get();
});
$view->with('headerMenu', $headerMenu);
//footer menu
$footerMenu = Cache::rememberForever('footerMenu', function () {
return Page::select('page_title', 'page_slug')->where('page_position', Page::FOOTER_MENU)->where('page_active', 1)->orderBy('page_ord', 'ASC')->get();
});
$view->with('footerMenu', $footerMenu);
//get central banner if any
$today = date('Y-m-d');
$centralBanner = Banner::where('banner_active_from', '<=', $today)->where('banner_active_to', '>=', $today)->where('banner_position', Banner::BANNER_POSITION_LIST)->orderByRaw('rand()')->take(1)->first();
if (!empty($centralBanner)) {
$centralBanner->increment('banner_num_views');
}
$view->with('centralBanner', $centralBanner);
});
/**
* get ad detail/ad contact banner
*/
view()->composer(['ad.detail', 'ad.contact'], function ($view) {
$today = date('Y-m-d');
$adDetailBanner = Banner::where('banner_active_from', '<=', $today)->where('banner_active_to', '>=', $today)->where('banner_position', Banner::BANNER_POSITION_DETAIL)->orderByRaw('rand()')->take(1)->first();
if (!empty($adDetailBanner)) {
$adDetailBanner->increment('banner_num_views');
}
$view->with('adDetailBanner', $adDetailBanner);
});
}