Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 9db5f72

Browse files
committed
Enable page views count
1 parent b17297d commit 9db5f72

File tree

20 files changed

+374
-9
lines changed

20 files changed

+374
-9
lines changed

app/Http/Controllers/BlogController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function category(string $slug)
6969
public function post(string $slug)
7070
{
7171
$post = $this->postRepository->findBySlug($slug);
72+
$post->addView();
7273

7374
return view('frontend.blog.post', compact('post'));
7475
}

app/Http/Controllers/PackageController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function category(string $slug)
6868
public function post(string $slug)
6969
{
7070
$package = $this->repository->findBySlug($slug);
71+
$package->addView();
7172

7273
return view('frontend.packages.post', compact('package'));
7374
}

app/Http/Controllers/TutorialController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function category(string $slug)
6767
public function post(string $slug)
6868
{
6969
$tutorial = $this->repository->findBySlug($slug);
70+
$tutorial->addView();
7071

7172
return view('frontend.tutorials.post', compact('tutorial'));
7273
}

app/Models/Category.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace App\Models;
44

5+
use CyrildeWit\EloquentViewable\Viewable;
6+
57
class Category extends \TCG\Voyager\Models\Category
68
{
9+
use Viewable;
10+
11+
/**
12+
* @var array
13+
*/
714
protected $fillable = ['slug', 'name', 'type'];
815

916
/**

app/Models/Package.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
namespace App\Models;
44

55
use App\User;
6+
use CyrildeWit\EloquentViewable\Viewable;
67
use Illuminate\Database\Eloquent\Model;
78

89
class Package extends Model
910
{
11+
use Viewable;
12+
1013
/**
1114
* The attributes that are mass assignable.
1215
*

app/Models/Post.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use CyrildeWit\EloquentViewable\Viewable;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Post extends \TCG\Voyager\Models\Post
9+
{
10+
use Viewable;
11+
}

app/Models/Tutorial.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
namespace App\Models;
44

55
use App\User;
6+
use CyrildeWit\EloquentViewable\Viewable;
67
use Illuminate\Database\Eloquent\Model;
78

89
class Tutorial extends Model
910
{
11+
use Viewable;
12+
1013
/**
1114
* The attributes that are mass assignable.
1215
*

app/Repositories/PostRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace App\Repositories;
99

10-
use TCG\Voyager\Models\Post;
10+
use App\Models\Post;
1111

1212
class PostRepository
1313
{

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "project",
1010
"require": {
1111
"php": "^7.1.3",
12+
"cyrildewit/eloquent-viewable": "^2.1",
1213
"devdojo/chatter": "0.2.*",
1314
"fideloper/proxy": "^4.0",
1415
"graham-campbell/markdown": "^10.0",

composer.lock

Lines changed: 125 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)