當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。