1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Raystech\StarterKit\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
6
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
7
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests; |
8
|
|
|
use Illuminate\Routing\Controller as BaseController; |
9
|
|
|
use Illuminate\Http\Request; |
10
|
|
|
|
11
|
|
|
use Raystech\StarterKit\Models\Term; |
12
|
|
|
use Raystech\StarterKit\Models\TermTaxonomy; |
13
|
|
|
|
14
|
|
|
class TermController extends BaseController |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Display a listing of the resource. |
18
|
|
|
* |
19
|
|
|
* @return \Illuminate\Http\Response |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
public function index(Request $request) |
24
|
|
|
{ |
25
|
|
|
$parent = $request->get('term_id') ?? 0; |
26
|
|
|
if($request->has('taxonomy')) { |
27
|
|
|
$taxonomy = $request->taxonomy; |
28
|
|
|
} else { |
29
|
|
|
$taxonomy = 'rt_data_structure'; |
30
|
|
|
} |
31
|
|
|
$term_taxonomy = TermTaxonomy::where('taxonomy', $taxonomy)->where('parent', $parent)->get(); |
32
|
|
|
$term = Term::find($parent); |
33
|
|
|
// $terms = Term::where('')->get(); |
34
|
|
|
return view('rt-starter-kit::terms.index', compact([ |
|
|
|
|
35
|
|
|
'taxonomy', 'term_taxonomy', 'term' |
36
|
|
|
])); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Show the form for creating a new resource. |
41
|
|
|
* |
42
|
|
|
* @return \Illuminate\Http\Response |
43
|
|
|
*/ |
44
|
|
|
public function create() |
45
|
|
|
{ |
46
|
|
|
// |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Store a newly created resource in storage. |
51
|
|
|
* |
52
|
|
|
* @param \Illuminate\Http\Request $request |
53
|
|
|
* @return \Illuminate\Http\Response |
54
|
|
|
*/ |
55
|
|
|
public function store(Request $request) |
56
|
|
|
{ |
57
|
|
|
// dd($request->all()); |
58
|
|
|
$request->validate([ |
59
|
|
|
'name' => 'required', |
60
|
|
|
'taxonomy' => 'required', |
61
|
|
|
]); |
62
|
|
|
|
63
|
|
|
$term = Term::create([ |
64
|
|
|
'name' => $request->get('name') |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
$term_taxonomy = TermTaxonomy::create([ |
|
|
|
|
68
|
|
|
'term_id' => $term->id, |
69
|
|
|
'taxonomy' => $request->taxonomy, |
70
|
|
|
'description' => $request->description, |
71
|
|
|
'parent' => $request->get('term_id') ?? 0, |
72
|
|
|
'count' => 0 |
73
|
|
|
]); |
74
|
|
|
return redirect()->back(); |
|
|
|
|
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Display the specified resource. |
80
|
|
|
* |
81
|
|
|
* @param int $id |
82
|
|
|
* @return \Illuminate\Http\Response |
83
|
|
|
*/ |
84
|
|
|
public function show($id) |
|
|
|
|
85
|
|
|
{ |
86
|
|
|
// |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Show the form for editing the specified resource. |
91
|
|
|
* |
92
|
|
|
* @param int $id |
93
|
|
|
* @return \Illuminate\Http\Response |
94
|
|
|
*/ |
95
|
|
|
public function edit($id) |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
// |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Update the specified resource in storage. |
102
|
|
|
* |
103
|
|
|
* @param \Illuminate\Http\Request $request |
104
|
|
|
* @param int $id |
105
|
|
|
* @return \Illuminate\Http\Response |
106
|
|
|
*/ |
107
|
|
|
public function update(Request $request, $id) |
|
|
|
|
108
|
|
|
{ |
109
|
|
|
// |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Remove the specified resource from storage. |
114
|
|
|
* |
115
|
|
|
* @param int $id |
116
|
|
|
* @return \Illuminate\Http\Response |
117
|
|
|
*/ |
118
|
|
|
public function destroy($id) |
|
|
|
|
119
|
|
|
{ |
120
|
|
|
// |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|