category = $category; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { /*$root = Category::create(['name' => 'Root category2']); $child1 = $root->children()->create(['name' => 'Child 1']); // with the `makeChildOf` method $child2 = Category::create(['name' => 'Child 2']); $child2->makeChildOf($root); exit();*/ $category = $this->category->getNestedList(); return view("backend.category.index", compact('category')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.category.create'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CreateRequest $request) { dd($request); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $category = $this->category->find($id); return view('backend.category.edit', compact('category')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(UpdateRequest $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Category::find($id); if ($category) { if ($category->delete()) { return response()->json(['status' => 0]); } } return response()->json(['status' => 1]); } }