Skip to content

Commit e9a4a1f

Browse files
Caching changed
1 parent 6cfc673 commit e9a4a1f

13 files changed

+38
-35
lines changed

.idea/DefaultTheme.iml

100644100755
File mode changed.

.idea/misc.xml

100644100755
File mode changed.

.idea/modules.xml

100644100755
File mode changed.

.idea/vcs.xml

100644100755
File mode changed.

.idea/workspace.xml

100644100755
File mode changed.

controllers/CategoryController.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use App\Models\Category;
77
use App\Models\Post;
8+
use App\Models\PostType;
89
use App\Models\Theme;
910
use Illuminate\Http\Request;
1011
use App\Http\Controllers\Frontend\MainController;
@@ -40,13 +41,19 @@ public function posts(Request $request){
4041
return error404();
4142
}
4243

43-
$posts = Post::cache("category_posts_".$category->categoryID, function($query) use($category){
44-
return $query->generateCacheByCategory($category->categoryID);
45-
})
46-
->published()
47-
->orderBy('published_at','DESC')
48-
->getItems()
49-
->paginate();
44+
$postType = PostType::findByID($category->postTypeID);
45+
$postObj = (new Post())->setTable($postType->slug);
46+
47+
$categoryTable = categoriesRelationTable($postType->slug);
48+
$posts = $postObj
49+
->join($categoryTable, $categoryTable.'.postID', $postType->slug . '.postID')
50+
->where($categoryTable.'.categoryID', $category->categoryID)
51+
->with($postObj->getDefaultRelations($postType))
52+
->where('status->'.\App::getLocale(),'published')
53+
->orderBy('published_at', 'DESC')
54+
->paginate(25);
55+
56+
$posts = Post::filterPublished($posts);
5057

5158
return view(Theme::view('category/posts'),compact('category', 'posts'));
5259
}

controllers/PagesController.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Themes\DefaultTheme\Controllers;
44

55
use App\Http\Controllers\Frontend\MainController;
6+
use App\Models\Article;
67
use App\Models\Post;
78
use App\Models\Theme;
89
use HTMLMin\HTMLMin\Http\Middleware\MinifyMiddleware;
@@ -33,7 +34,6 @@ public function homepage(){
3334
return view(Theme::view('pages/home'));
3435
}
3536

36-
3737
/**
3838
* This function is usually used to load a page
3939
* */
@@ -42,7 +42,6 @@ public function single(){
4242
if(!$post){
4343
return error404();
4444
}
45-
4645
return view(Theme::view('pages/single'),compact('post'));
4746
}
4847
}

controllers/PostController.php

+11-17
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22

33
namespace Themes\DefaultTheme\Controllers;
44

5-
use App\Models\Media;
6-
use App\Models\MediaRelation;
7-
use App\Models\MenuLink;
5+
use App\Models\Category;
86
use App\Models\Post;
97
use App\Models\PostType;
108
use App\Models\Theme;
11-
use Illuminate\Http\Request;
12-
use Illuminate\Support\Facades\Cache;
13-
use Illuminate\Support\Facades\Route;
14-
use Accio\App\Models\PostModel;
15-
use Accio\Support\Facades\Pagination;
169
use App\Http\Controllers\Frontend\MainController;
10+
use App\Models\User;
11+
use Illuminate\Support\Facades\Route;
12+
use Symfony\Component\Console\Input\Input;
1713

1814
class PostController extends MainController{
1915

@@ -50,23 +46,21 @@ public function index(){
5046
if(PostType::validatePostType()){
5147
return error404();
5248
}
53-
54-
$posts = Post::cache('post_articles')
55-
->published()
56-
->orderBy('published_at','DESC')
57-
->take(2)
58-
->getItems()
59-
->paginate(10);
49+
$postType = (\Request::route('postTypeSlug') ? \Request::route('postTypeSlug') : "post_articles");
50+
$posts = (new Post())->setTable($postType)
51+
->with(["categories", "featuredimage"])
52+
->orderBy('published_at','DESC')
53+
->paginate(10);
6054

6155
return view(Theme::view('posts/index'),compact('posts'));
6256
}
6357

6458
public function single(){
65-
$post = Post::findBySlug(\Request::route('postSlug'));
59+
$post = Post::findBySlug(\Request::route('postSlug'), "post_articles");
6660
if(!$post){
6761
return error404();
6862
}
6963

70-
return view(Theme::view('posts/single'),compact('post'));
64+
return view(Theme::view('posts/single'),compact('post', 'users'));
7165
}
7266
}

controllers/TagController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public function single(){
2323
//get posts by tag
2424
$postsObj = new Post();
2525
$postsObj->setTable(PostType::getSlug());
26-
$posts = $postsObj->join('tags_relations','tags_relations.belongsToID',PostType::getSlug().'.postID')
27-
->where('belongsTo',PostType::getSlug())
26+
$posts = $postsObj->join(PostType::getSlug().'_tags', PostType::getSlug().'_tags.postID',PostType::getSlug().'.postID')
2827
->with('featuredImage')
29-
->published()
3028
->where('tagID',$tag['tagID'])
3129
->orderBy('published_at','DESC')
3230
->paginate(16);
3331

32+
$posts = Post::filterPublished($posts);
33+
3434
return view(Theme::view('tags/single'),compact(['posts','tag']));
3535
}
3636
}

views/index.blade.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<?php event('theme:before_body'); ?>
2020
<body>
2121
<?php event('theme:body_start'); ?>
22+
2223
@section('header')
2324
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
2425
<a class="navbar-brand" href="#">Logo</a>
@@ -74,5 +75,6 @@
7475
{!! js(false, ['async' => true]) !!}
7576
@show
7677

78+
<?php event('theme:body_end'); ?>
7779
</body>
7880
</html>

views/pages/home.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('meta')
44
@parent
5-
{{metaTags(homepage())}}
5+
{{ metaTags(homepage()) }}
66
@endsection
77

88
@section('header')
@@ -18,4 +18,4 @@
1818
?>
1919
</p>
2020
</div>
21-
@endsection
21+
@endsection

views/posts/index.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@section('header')
66
@parent
7+
{{metaTags()}}
78
@endsection
89

910
@section('content')

views/posts/single.blade.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
@extends('DefaultTheme.views.index')
22

33
@section('meta')
4-
{{metaTags($post)}}
4+
{{--{{metaTags($post)}}--}}
55
@endsection
66

77
@section('content')
8+
89
<div class="container">
910
<div class="row">
10-
11-
1211
<div class="col-sm-8 blog-main">
1312

1413
<div class="blog-post">
@@ -32,7 +31,7 @@
3231

3332
<div class="post-content">
3433
<?php
35-
print $post->content();
34+
print $post->content();
3635
?>
3736
</div>
3837
</div>
@@ -76,4 +75,5 @@
7675
</div><!-- /.row -->
7776

7877
</div>
78+
7979
@endsection

0 commit comments

Comments
 (0)