1 | <?php namespace Arcanesoft\Blog\Http\Controllers\Admin; |
||
15 | class CategoriesController extends Controller |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * The category model. |
||
24 | * |
||
25 | * @var \Arcanesoft\Blog\Models\Category |
||
26 | */ |
||
27 | private $category; |
||
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Constructor |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * CategoriesController constructor. |
||
36 | * |
||
37 | * @param \Arcanesoft\Blog\Models\Category $category |
||
38 | */ |
||
39 | public function __construct(Category $category) |
||
40 | { |
||
41 | parent::__construct(); |
||
42 | |||
43 | $this->category = $category; |
||
44 | |||
45 | $this->setCurrentPage('blog-categories'); |
||
46 | $this->addBreadcrumbRoute(trans('blog::categories.titles.categories'), 'admin::blog.categories.index'); |
||
47 | } |
||
48 | |||
49 | /* ----------------------------------------------------------------- |
||
50 | | Main Methods |
||
51 | | ----------------------------------------------------------------- |
||
52 | */ |
||
53 | |||
54 | public function index($trashed = false) |
||
55 | { |
||
56 | $this->authorize(CategoriesPolicy::PERMISSION_LIST); |
||
57 | |||
58 | $categories = $this->category->with(['posts'])->when($trashed, function ($query) { |
||
|
|||
59 | return $query->onlyTrashed(); |
||
60 | })->paginate(30); |
||
61 | |||
62 | $this->setTitle($title = trans('blog::categories.titles.categories-list')); |
||
63 | $this->addBreadcrumb($title); |
||
64 | |||
65 | return $this->view('admin.categories.index', compact('categories', 'trashed')); |
||
66 | } |
||
67 | |||
68 | public function trash() |
||
69 | { |
||
70 | return $this->index(true); |
||
71 | } |
||
72 | |||
73 | public function create() |
||
74 | { |
||
75 | $this->authorize(CategoriesPolicy::PERMISSION_CREATE); |
||
76 | |||
77 | $this->setTitle($title = trans('blog::categories.titles.create-category')); |
||
78 | $this->addBreadcrumb($title); |
||
79 | |||
80 | return $this->view('admin.categories.create'); |
||
81 | } |
||
82 | |||
83 | public function store(CreateCategoryRequest $request) |
||
84 | { |
||
85 | $this->authorize(CategoriesPolicy::PERMISSION_CREATE); |
||
86 | |||
87 | $category = Category::createOne($request->getValidatedData()); |
||
88 | |||
89 | $this->transNotification('created', ['name' => $category->name], $category->toArray()); |
||
90 | |||
91 | return redirect()->route('admin::blog.categories.index'); |
||
92 | } |
||
93 | |||
94 | public function show(Category $category) |
||
105 | |||
106 | public function edit(Category $category) |
||
115 | |||
116 | public function update(Category $category, UpdateCategoryRequest $request) |
||
117 | { |
||
118 | $this->authorize(CategoriesPolicy::PERMISSION_UPDATE); |
||
119 | |||
120 | $category->updateOne($request->getValidatedData()); |
||
126 | |||
127 | public function delete(Category $category) |
||
142 | |||
143 | public function restore(Category $category) |
||
158 | |||
159 | /* ----------------------------------------------------------------- |
||
160 | | Other Methods |
||
161 | | ----------------------------------------------------------------- |
||
162 | */ |
||
163 | |||
164 | /** |
||
165 | * Notify with translation. |
||
166 | * |
||
167 | * @todo: Refactor this methods to the core package ? |
||
168 | * |
||
169 | * @param string $action |
||
170 | * @param array $replace |
||
171 | * @param array $context |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | protected function transNotification($action, array $replace = [], array $context = []) |
||
185 | } |
||
186 |
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: