示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Add transaction to secure against faulty errors
     DB::beginTransaction();
     // Reset table
     DB::table('positions')->truncate();
     $names = ['left', 'center', 'right'];
     // We use models to avoid null constraint violations
     // in the timestamp columns
     foreach ($names as $name) {
         $position = new Position();
         $position->id = Uuid::generate(4);
         $position->name = $name;
         $position->save();
     }
     DB::commit();
     $this->command->info('Box positions seeded');
 }
示例#2
0
 /**
  * Find all positions
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function allPositions()
 {
     return Position::all();
 }