当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::destroy方法代码示例

本文整理汇总了PHP中app\models\Category::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::destroy方法的具体用法?PHP Category::destroy怎么用?PHP Category::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Category的用法示例。


在下文中一共展示了Category::destroy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postCategories

 public function postCategories(Request $request)
 {
     if ($request->has('adds')) {
         $adds = $request->adds;
         for ($i = 0; $i < count($adds); $i++) {
             if ($adds[$i]['parent_id'] == 'null') {
                 Category::create(['title' => $adds[$i]['title']]);
             } else {
                 $parent = Category::find($adds[$i]['parent_id']);
                 $child = $parent->children()->create(['title' => $adds[$i]['title'], 'slug' => str_slug($adds[$i]['title'])]);
                 for ($j = 0; $j < count($adds); $j++) {
                     if ($adds[$j]['parent_id'] == $adds[$i]['id']) {
                         $adds[$j]['parent_id'] = $child->id;
                     }
                 }
             }
         }
     }
     if ($request->has('updates')) {
         $updates = $request->updates;
         for ($i = 0; $i < count($updates); $i++) {
             $category = Category::find($updates[$i]['id']);
             $category->update(['title' => $updates[$i]['title'], 'slug' => str_slug($updates[$i]['title'])]);
         }
     }
     if ($request->has('deletes')) {
         $deletes = $request->deletes;
         for ($i = 0; $i < count($deletes); $i++) {
             Category::destroy($deletes[$i]);
         }
     }
 }
开发者ID:ninjamonz,项目名称:laravel_catalog_example,代码行数:32,代码来源:CategoriesController.php

示例2: destroy

 public function destroy($id)
 {
     Cache::forget('admin_category_categories_wfh');
     Cache::forget('wechat_index_categories_wfh');
     Category::destroy($id);
     return back();
 }
开发者ID:noikiy,项目名称:wfhshop_wechat_laravel,代码行数:7,代码来源:CategoryController.php

示例3: delete

 /**
  * delete data
  * @return json
  */
 public function delete()
 {
     $id = (int) $_POST['id'];
     $info = DB::select('select * from it_categories where parent_id = ?', [$id]);
     if ($info) {
         return response()->json(['status' => 100, 'message' => 'This category has child category cannot be deleted~~ ']);
     }
     $rs = Category::destroy($id);
     if ($rs) {
         return response()->json(['status' => 200, 'message' => 'Deleted Successfully~~']);
     } else {
         return response()->json(['status' => 400, 'message' => 'Delete Failure~~']);
     }
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:18,代码来源:CategoryController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy([$id]);
     return redirect('category');
 }
开发者ID:haclongkim,项目名称:newsedu,代码行数:11,代码来源:CategoryController.php

示例5: destroy

 /**
  * Remove the specified category from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     return Redirect::route('categories.index');
 }
开发者ID:lyovkin,项目名称:v2board,代码行数:11,代码来源:CategoriesController.php

示例6: delete

 public function delete($categoryID)
 {
     Category::destroy($categoryID);
     header("Location: " . base . "/Category");
 }
开发者ID:blegoh,项目名称:Web,代码行数:5,代码来源:CategoryController.php

示例7: destroy

 public function destroy($id)
 {
     Cache::forget('wyshop_admin_category_categories');
     Category::destroy($id);
     return back()->with('info', '删除分类成功');
 }
开发者ID:beidouzhiguang,项目名称:wy_shop,代码行数:6,代码来源:CategoryController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($result = check_auth_to('FLGL_DELETE')) {
         return $result;
     }
     try {
         $count = Category::where('parent_id', '=', $id)->count();
         if ($count !== 0) {
             throw new \Exception("请先删除下级分类");
         }
         Category::destroy($id);
         return redirect()->action('Admin\\CategoryController@index')->with('operationstatus', 'sucess');
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(['error' => '删除文章分类失败,请重试(' . $e->getMessage() . ')']);
     }
 }
开发者ID:xinzou,项目名称:blog,代码行数:22,代码来源:CategoryController.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     Session::flash('flash_message', 'Category deleted!');
     return redirect('backoffice/categories');
 }
开发者ID:AntonBeletsky,项目名称:laravel_minishop,代码行数:13,代码来源:CategoriesController.php


注:本文中的app\models\Category::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。