コード例 #1
0
 /**
  * Remove the category.
  *
  * @param Request $request
  * @param Model   $category
  *
  * @return json
  */
 public function destroy(CategoryAdminApiRequest $request, Category $category)
 {
     try {
         $t = $category->delete();
         return response()->json(['message' => trans('messages.success.delete', ['Module' => trans('blog::category.name')]), 'code' => 2006])->setStatusCode(202, 'DESTROY_SUCCESS');
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 4006])->setStatusCode(400, 'DESTROY_ERROR');
     }
 }
コード例 #2
0
 /**
  * Remove the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy(CategoryUserRequest $request, Category $category)
 {
     try {
         $this->repository->delete($category->getRouteKey());
         return redirect(trans_url('/user/blog/category'))->with('message', trans('messages.success.deleted', ['Module' => trans('blog::category.name')]))->with('code', 204);
     } catch (Exception $e) {
         redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400);
     }
 }
コード例 #3
0
 public function transform(\Litecms\Blog\Models\Category $category)
 {
     return ['id' => $category->getRouteKey(), 'name' => ucfirst($category->name), 'status' => $category->status];
 }
コード例 #4
0
 /**
  * Remove the category.
  *
  * @param Model   $category
  *
  * @return Response
  */
 public function destroy(CategoryAdminRequest $request, Category $category)
 {
     try {
         $t = $category->delete();
         return response()->json(['message' => trans('messages.success.deleted', ['Module' => trans('blog::category.name')]), 'code' => 202, 'redirect' => trans_url('/admin/blog/category/0')], 202);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/blog/category/' . $category->getRouteKey())], 400);
     }
 }