This repository has been archived by the owner on May 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
63 lines (55 loc) · 1.94 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
if(!function_exists('pagers_by_id')) {
function pagers_by_id($id)
{
$pager = \Module\Content\Models\Pager::where('id', '=', $id)->firstOrFail();
$pager->template = $pager->template ? $pager->template : 'default';
$pager->content = base64_decode($pager->content);
$pager->additional = unserialize($pager->additional);
return $pager;
}
}
if(!function_exists('pagers_by_tag')){
function pagers_by_tag($tag){
$pager = \Module\Content\Models\Pager::where('tag','=',$tag)->firstOrFail();
$pager->template = $pager->template ? $pager->template : 'default';
$pager->content = base64_decode($pager->content);
$pager->additional = unserialize($pager->additional);
return $pager;
}
}
if(!function_exists('pagers_by_category_ids')){
function pagers_by_category_ids($cid){
return \Module\Content\Models\Pager::whereIn('category_id',$cid)
->orderByRaw('field(category_id,'.implode(',',$cid).')')
->get()->map(function($pager){
$pager->template = $pager->template ? $pager->template : 'default';
$pager->content = base64_decode($pager->content);
$pager->additional = unserialize($pager->additional);
return $pager;
});
}
}
if(!function_exists('pagers_is_current')) {
function pagers_is_current($pager)
{
$id = \Illuminate\Support\Facades\Session::get('_current_page_', null);
if (!isset($pager->id)) {
return false;
}
if ($id == $pager->id) {
return true;
} else {
return false;
}
}
}
if(!function_exists('pagers_set_current')) {
function pagers_set_current($pager){
if(isset($pager->id)){
\Illuminate\Support\Facades\Session::put('_current_page_', $pager->id);
}else{
\Illuminate\Support\Facades\Session::forget('_current_page_');
}
}
}