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


PHP Category::withTrashed方法代码示例

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


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

示例1: editCategory

 public function editCategory()
 {
     $data = \Input::all();
     $id = $data['id'];
     $name = $data['name'];
     $exist = Category::withTrashed()->where('id', '!=', $id)->where('name', '=', $name)->get()->first();
     if ($exist) {
         $retData['data'] = $exist;
         $retData['status'] = 409;
     } else {
         $category = Category::find($id);
         $category->name = $name;
         $category->parent_id = $data['parent_id'];
         $retData['status'] = $category->save() ? 200 : 500;
     }
     return \Response::json($retData);
 }
开发者ID:sujithma,项目名称:AccountsTransaction,代码行数:17,代码来源:CategoryController.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Videos
     echo 'UPDATING VIDEOS', PHP_EOL, '===============', PHP_EOL;
     $count = 0;
     Video::withTrashed()->with('category')->chunk(200, function ($videos) use($count) {
         foreach ($videos as $v) {
             echo 'Updating Video with ID: ', $v->id, PHP_EOL;
             $v->detag();
             // quick and dirty. not 100% correct though.
             if ($v->category->shortname === 'pr0n') {
                 $v->tag('nsfw');
             } else {
                 $v->tag('sfw');
             }
             $v->tag(array_filter([$v->category->shortname, $v->category->name, $v->interpret, $v->songtitle, $v->imgsource], function ($elem) {
                 return !empty(trim($elem));
             }));
             $count++;
         }
     });
     echo PHP_EOL, PHP_EOL, 'Updated ', $count, ' Videos.', PHP_EOL, PHP_EOL, PHP_EOL;
     // User filters
     echo 'UPDATING USERS', PHP_EOL, '==============', PHP_EOL;
     $count = 0;
     $categories = Category::withTrashed()->get()->keyBy('id');
     User::withTrashed()->chunk(200, function ($users) use(&$count, $categories) {
         foreach ($users as $u) {
             echo 'Updating User: ', $u->username, PHP_EOL;
             $u->categories = array_values($categories->filter(function ($cat) use($u) {
                 return !in_array($cat->id, $u->categories);
             })->map(function ($cat) {
                 return $cat->shortname;
             })->all());
             $u->save();
             $count++;
         }
     });
     echo PHP_EOL, PHP_EOL, 'Updated ', $count, ' Users.', PHP_EOL, PHP_EOL, PHP_EOL;
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:45,代码来源:AddTags.php


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