public function post_terms() { $input = Input::all(); if ($input['submit'] == 'save') { if ($input['id'] > 0) { $terms = Term::find($input['id']); $terms->update($input); } else { $terms = new Term(); $terms->create($input); } } else { if ($input['id'] > 0) { Term::destroy($input['id']); } } return redirect('terms')->with('message', 'Terms have been updated successfully'); }
public function post_categories(Request $request) { $categories = \App\Term::where('type', 'post_category')->get(); if ($request->action == 'create') { return view('admin.pages.post.category-create', compact('categories')); } if ($request->action == 'edit' && isset($request->id)) { $term = \App\Term::find($request->id); return view('admin.pages.post.category-edit', compact('term', 'categories')); } return view('admin.pages.post.category-listing'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $term = Term::find($id); if (in_array($term->id, [1, 2, 3, 4, 5, 6])) { return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => 'you are not allowed to delete this item'))); } $term->delete(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'object has been deleted'), 'id' => $id)); }