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


PHP Board::chunk方法代码示例

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


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

示例1: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('board_adventures', function (Blueprint $table) {
         $table->increments('adventure_id');
         $table->binary('adventurer_ip');
         $table->string('board_uri', 32);
         $table->integer('post_id')->unsigned()->nullable()->default(NULL);
         $table->timestamps();
         $table->timestamp('expires_at');
         $table->timestamp('expended_at')->nullable()->default(NULL);
         $table->foreign('board_uri')->references('board_uri')->on('boards')->onDelete('cascade')->onUpdate('cascade');
     });
     Schema::table('posts', function (Blueprint $table) {
         $table->integer('adventure_id')->unsigned()->nullable()->default(NULL)->after('locked_at');
         $table->foreign('adventure_id')->references('adventure_id')->on('board_adventures')->onDelete('set null')->onUpdate('cascade');
     });
     Schema::table('boards', function (Blueprint $table) {
         $table->timestamp('last_post_at')->nullable()->default(NULL)->after('updated_at');
     });
     Board::chunk(100, function ($boards) {
         foreach ($boards as $board) {
             $lastPost = $board->posts()->orderBy('created_at', 'desc')->limit(1)->get()->last();
             if ($lastPost) {
                 $board->last_post_at = $lastPost->created_at;
                 $board->save();
             }
         }
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:34,代码来源:2015_08_31_021154_adventure_mode.php

示例2: runBoards

 public function runBoards()
 {
     $this->command->comment("\tInserting board owner roles.");
     $boardRole = $this->slugs()[Role::ID_OWNER];
     Board::chunk(50, function ($boards) {
         foreach ($boards as $board) {
             $boardRole = $board->getOwnerRole();
             if (!$boardRole) {
                 $boardRole = Role::getOwnerRoleForBoard($board);
                 $this->command->line("\t/{$board->board_uri}/ has no owner role.");
             }
             $roleModel = Role::firstOrCreate(['role' => $boardRole['role'], 'board_uri' => $board->board_uri, 'caste' => $boardRole['caste']]);
             if ($roleModel->wasRecentlyCreated) {
                 $roleModel->fill(['name' => $boardRole['name'], 'capcode' => $boardRole['capcode'], 'inherit_id' => Role::ID_OWNER, 'system' => false, 'weight' => $boardRole['weight'] + 5])->save();
             }
         }
     });
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:18,代码来源:RoleSeeder.php


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