laravel factory counter

40

class OrderFactory extends Factory {
  private static $order = 1; 	//Static iterator
  protected $model = Order::class;

  public function definition() {
    return [
    	'counting_wow' => self::$order++	//Adds then Increments $order
    ];
  }
}

Comments

Submit
0 Comments