3
3
namespace Chriscreates \Blog \Controllers ;
4
4
5
5
use Chriscreates \Blog \Category ;
6
+ use Chriscreates \Blog \Requests \ValidateCategoryRequest ;
6
7
use Illuminate \Http \Request ;
7
8
8
9
class CategoryController extends Controller
9
10
{
10
11
/**
11
- * Instantiate a new controller instance .
12
+ * Display a listing of the resource .
12
13
*
13
- * @return void
14
+ * @return \Illuminate\Http\Response
14
15
*/
15
- public function __construct ()
16
+ public function index ()
16
17
{
17
- $ this ->middleware ('auth ' );
18
18
}
19
19
20
20
/**
21
- * Display a listing of the resource.
21
+ * Show the form for creating a new resource.
22
22
*
23
23
* @return \Illuminate\Http\Response
24
24
*/
25
- public function index () : JsonResponse
25
+ public function create ()
26
26
{
27
27
}
28
28
@@ -32,7 +32,24 @@ public function index() : JsonResponse
32
32
* @param \Chriscreates\Blog\Requests\ValidateCategoryRequest $request
33
33
* @return \Illuminate\Http\Response
34
34
*/
35
- public function store (ValidateCategoryRequest $ request ) : JsonResponse
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 )
36
53
{
37
54
}
38
55
@@ -42,18 +59,18 @@ public function store(ValidateCategoryRequest $request) : JsonResponse
42
59
* @param \Chriscreates\Blog\Category $category
43
60
* @return \Illuminate\Http\Response
44
61
*/
45
- public function edit (Category $ category ) : JsonResponse
62
+ public function edit (Category $ category )
46
63
{
47
64
}
48
65
49
66
/**
50
67
* Update the specified resource in storage.
51
68
*
69
+ * @param \Illuminate\Http\Request $request
52
70
* @param \Chriscreates\Blog\Requests\ValidateCategoryRequest $request
53
- * @param \Chriscreates\Blog\Category $category
54
71
* @return \Illuminate\Http\Response
55
72
*/
56
- public function update (ValidateCategoryRequest $ request , Category $ category ) : JsonResponse
73
+ public function update (ValidateCategoryRequest $ request , Category $ category )
57
74
{
58
75
}
59
76
@@ -63,7 +80,7 @@ public function update(ValidateCategoryRequest $request, Category $category) : J
63
80
* @param \Chriscreates\Blog\Category $category
64
81
* @return \Illuminate\Http\Response
65
82
*/
66
- public function destroy (Category $ category ) : JsonResponse
83
+ public function destroy (Category $ category )
67
84
{
68
85
}
69
86
}
0 commit comments