|
1
|
|
|
<?php namespace Arcanesoft\Blog\Http\Controllers\Foundation; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Blog\Bases\FoundationController; |
|
4
|
|
|
use Arcanesoft\Blog\Models\Post; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class PostsController |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanesoft\Blog\Http\Controllers\Foundation |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class PostsController extends FoundationController |
|
13
|
|
|
{ |
|
14
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
15
|
|
|
| Properties |
|
16
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
17
|
|
|
*/ |
|
18
|
|
|
/** |
|
19
|
|
|
* The post model. |
|
20
|
|
|
* |
|
21
|
|
|
* @var \Arcanesoft\Blog\Models\Post |
|
22
|
|
|
*/ |
|
23
|
|
|
private $post; |
|
24
|
|
|
|
|
25
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
26
|
|
|
| Constructor |
|
27
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
28
|
|
|
*/ |
|
29
|
|
|
/** |
|
30
|
|
|
* Instantiate the controller. |
|
31
|
|
|
* |
|
32
|
|
|
* @param Post $post |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(Post $post) |
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct(); |
|
37
|
|
|
|
|
38
|
|
|
$this->post = $post; |
|
39
|
|
|
|
|
40
|
|
|
$this->setCurrentPage('blog-posts'); |
|
41
|
|
|
$this->addBreadcrumbRoute('Posts', 'blog::foundation.posts.index'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
45
|
|
|
| Main Functions |
|
46
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
47
|
|
|
*/ |
|
48
|
|
|
/** |
|
49
|
|
|
* List the posts. |
|
50
|
|
|
* |
|
51
|
|
|
* @param bool $trashed |
|
52
|
|
|
* |
|
53
|
|
|
* @return \Illuminate\View\View |
|
54
|
|
|
*/ |
|
55
|
|
|
public function index($trashed = false) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->authorize('blog.posts.list'); |
|
58
|
|
|
|
|
59
|
|
|
$posts = $trashed |
|
60
|
|
|
? $this->post->onlyTrashed()->paginate(30) |
|
|
|
|
|
|
61
|
|
|
: $this->post->paginate(30); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$title = 'List of posts' . ($trashed ? ' - Trashed' : ''); |
|
64
|
|
|
$this->setTitle($title); |
|
65
|
|
|
$this->addBreadcrumb($title); |
|
66
|
|
|
|
|
67
|
|
|
return $this->view('foundation.posts.list', compact('trashed', 'posts')); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* List the trashed posts. |
|
72
|
|
|
* |
|
73
|
|
|
* @return \Illuminate\View\View |
|
74
|
|
|
*/ |
|
75
|
|
|
public function trash() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->index(true); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function create() |
|
81
|
|
|
{ |
|
82
|
|
|
// |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function store() |
|
86
|
|
|
{ |
|
87
|
|
|
// |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function show($post) |
|
|
|
|
|
|
91
|
|
|
{ |
|
92
|
|
|
// |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function edit($post) |
|
|
|
|
|
|
96
|
|
|
{ |
|
97
|
|
|
// |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function update($post) |
|
|
|
|
|
|
101
|
|
|
{ |
|
102
|
|
|
// |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function publish($post) |
|
|
|
|
|
|
106
|
|
|
{ |
|
107
|
|
|
// |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function restore($post) |
|
|
|
|
|
|
111
|
|
|
{ |
|
112
|
|
|
// |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function delete($post) |
|
|
|
|
|
|
116
|
|
|
{ |
|
117
|
|
|
// |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: