/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Create a table
     Schema::create('minimaps', function ($table) {
         $table->increments('id');
         $table->integer('mapid');
         $table->timestamp('updated_at');
         $table->boolean('locked')->default(false);
     });
     // Alter map table to so we can compare updated_at later
     if (!Schema::hasColumn('maps', 'updated_at')) {
         Schema::table('maps', function ($table) {
             $table->timestamps();
         });
     }
     // Create entries for each map
     $maps = Map::all();
     foreach ($maps as $map) {
         $minimap = new Minimap();
         $minimap->mapid = $map->id;
         $minimap = $map->minimap()->save($minimap);
     }
 }
Exemple #2
0
 public function test_all()
 {
     $nums = new Map(range(0, 9));
     $even = $nums->all(function ($val, $key) {
         return 0 == $val % 2;
     });
     $odds = $nums->all('1 == ($_0 % 2)');
     $this->assertSame(array_combine([0, 2, 4, 6, 8], [0, 2, 4, 6, 8]), $even->toArray());
     $this->assertSame(array_combine([1, 3, 5, 7, 9], [1, 3, 5, 7, 9]), $odds->toArray());
 }