|
1
|
|
|
<?php namespace Modules\Blog\Http\Controllers\Admin; |
|
2
|
|
|
|
|
3
|
|
|
use Modules\Blog\Entities\Category; |
|
4
|
|
|
use Modules\Blog\Http\Requests\StoreCategoryRequest; |
|
5
|
|
|
use Modules\Blog\Http\Requests\UpdateCategoryRequest; |
|
6
|
|
|
use Modules\Blog\Repositories\CategoryRepository; |
|
7
|
|
|
use Modules\Core\Http\Controllers\Admin\AdminBaseController; |
|
8
|
|
|
|
|
9
|
|
|
class CategoryController extends AdminBaseController |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var CategoryRepository |
|
13
|
|
|
*/ |
|
14
|
|
|
private $category; |
|
15
|
|
|
|
|
16
|
|
|
public function __construct(CategoryRepository $category) |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct(); |
|
19
|
|
|
|
|
20
|
|
|
$this->category = $category; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Display a listing of the resource. |
|
25
|
|
|
* |
|
26
|
|
|
* @return Response |
|
27
|
|
|
*/ |
|
28
|
|
|
public function index() |
|
29
|
|
|
{ |
|
30
|
|
|
$categories = $this->category->all(); |
|
31
|
|
|
|
|
32
|
|
|
return view('blog::admin.categories.index', compact('categories')); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Show the form for creating a new resource. |
|
37
|
|
|
* |
|
38
|
|
|
* @return Response |
|
39
|
|
|
*/ |
|
40
|
|
|
public function create() |
|
41
|
|
|
{ |
|
42
|
|
|
return view('blog::admin.categories.create'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Store a newly created resource in storage. |
|
47
|
|
|
* |
|
48
|
|
|
* @param StoreCategoryRequest $request |
|
49
|
|
|
* @return Response |
|
50
|
|
|
*/ |
|
51
|
|
|
public function store(StoreCategoryRequest $request) |
|
52
|
|
|
{ |
|
53
|
|
|
$this->category->create($request->all()); |
|
54
|
|
|
|
|
55
|
|
|
flash(trans('blog::messages.category created')); |
|
56
|
|
|
|
|
57
|
|
|
return redirect()->route('admin.blog.category.index'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Show the form for editing the specified resource. |
|
62
|
|
|
* |
|
63
|
|
|
* @param Category $category |
|
64
|
|
|
* @return Response |
|
65
|
|
|
*/ |
|
66
|
|
|
public function edit(Category $category) |
|
67
|
|
|
{ |
|
68
|
|
|
return view('blog::admin.categories.edit', compact('category')); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Update the specified resource in storage. |
|
73
|
|
|
* |
|
74
|
|
|
* @param Category $category |
|
75
|
|
|
* @param UpdateCategoryRequest $request |
|
76
|
|
|
* @return Response |
|
77
|
|
|
*/ |
|
78
|
|
|
public function update(Category $category, UpdateCategoryRequest $request) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->category->update($category, $request->all()); |
|
81
|
|
|
|
|
82
|
|
|
flash(trans('blog::messages.category updated')); |
|
83
|
|
|
|
|
84
|
|
|
return redirect()->route('admin.blog.category.index'); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Remove the specified resource from storage. |
|
89
|
|
|
* |
|
90
|
|
|
* @param Category $category |
|
91
|
|
|
* @return Response |
|
92
|
|
|
*/ |
|
93
|
|
|
public function destroy(Category $category) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->category->destroy($category); |
|
96
|
|
|
|
|
97
|
|
|
flash(trans('blog::messages.category deleted')); |
|
98
|
|
|
|
|
99
|
|
|
return redirect()->route('admin.blog.category.index'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|