1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Chriscreates\Blog\Controllers; |
4
|
|
|
|
5
|
|
|
use Chriscreates\Blog\Category; |
6
|
|
|
use Chriscreates\Blog\Requests\ValidateCategoryRequest; |
7
|
|
|
use Illuminate\Http\Request; |
8
|
|
|
|
9
|
|
|
class CategoryController extends Controller |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Display a listing of the resource. |
13
|
|
|
* |
14
|
|
|
* @return \Illuminate\Http\Response |
15
|
|
|
*/ |
16
|
|
|
public function index() |
17
|
|
|
{ |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Show the form for creating a new resource. |
22
|
|
|
* |
23
|
|
|
* @return \Illuminate\Http\Response |
24
|
|
|
*/ |
25
|
|
|
public function create() |
26
|
|
|
{ |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Store a newly created resource in storage. |
31
|
|
|
* |
32
|
|
|
* @param \Chriscreates\Blog\Requests\ValidateCategoryRequest $request |
33
|
|
|
* @return \Illuminate\Http\Response |
34
|
|
|
*/ |
35
|
|
|
public function store(ValidateCategoryRequest $request) |
36
|
|
|
{ |
37
|
|
|
$category = Category::create($request->only([ |
38
|
|
|
'name', |
39
|
|
|
'slug', |
40
|
|
|
'parent_id', |
41
|
|
|
])); |
42
|
|
|
|
43
|
|
|
return response()->json($category); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Display the specified resource. |
48
|
|
|
* |
49
|
|
|
* @param \Chriscreates\Blog\Category $category |
50
|
|
|
* @return \Illuminate\Http\Response |
51
|
|
|
*/ |
52
|
|
|
public function show(Category $category) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Show the form for editing the specified resource. |
58
|
|
|
* |
59
|
|
|
* @param \Chriscreates\Blog\Category $category |
60
|
|
|
* @return \Illuminate\Http\Response |
61
|
|
|
*/ |
62
|
|
|
public function edit(Category $category) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Update the specified resource in storage. |
68
|
|
|
* |
69
|
|
|
* @param \Illuminate\Http\Request $request |
70
|
|
|
* @param \Chriscreates\Blog\Requests\ValidateCategoryRequest $request |
71
|
|
|
* @return \Illuminate\Http\Response |
72
|
|
|
*/ |
73
|
|
|
public function update(ValidateCategoryRequest $request, Category $category) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Remove the specified resource from storage. |
79
|
|
|
* |
80
|
|
|
* @param \Chriscreates\Blog\Category $category |
81
|
|
|
* @return \Illuminate\Http\Response |
82
|
|
|
*/ |
83
|
|
|
public function destroy(Category $category) |
|
|
|
|
84
|
|
|
{ |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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: