12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Repositories;
- use App\Models\Page;
- use Illuminate\Support\Facades\Cache;
- use Prettus\Repository\Eloquent\BaseRepository;
- class PageRepository extends BaseRepository
- {
-
- public function model()
- {
- return Page::class;
- }
- public static function pageCache()
- {
-
- $cache = '';
-
- $where = array();
- if (null === $pageList = Cache::get('Home_page_list'.$cache)) {
- $pages = Page::select('alias', 'id', 'pname', 'route', 'rewrite', 'url', 'tag', 'caching')->where($where)->get();
- foreach ($pages as $key => $val) {
- $pageList[$val->alias] = $val;
- $pageList[$val->alias]->lower_route = strtolower($val->route);
- }
- Cache::forever('Home_page_list'.$cache, $pageList);
- }
- return $pageList;
- }
- public function getPage()
- {
-
- $cache = '_';
- $page_seo = Cache::get('Home_page_seo_list'.$cache);
- if ($page_seo === null) {
- $page_seo = $this->pageSeoCache();
- Cache::forever('Home_page_seo_list'.$cache, $page_seo);
- }
- return $page_seo;
- }
- public function pageSeoCache()
- {
- $where = array();
-
- $pageList = $this->model->where($where)->get()->toArray();
- $page = array();
- if ($pageList) {
- foreach ($pageList as $key => $val) {
- if ($val['route']) {
- $page[strtolower($val['route'])] = array('title'=>$val['title'],'keywords'=>$val['keywords'],'description'=>$val['description']);
- }
- }
- }
- return $page;
- }
- }
|