Answers for "laravel factory counter"

PHP
0

laravel factory counter

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
    ];
  }
}
Posted by: Guest on October-13-2021

Browse Popular Code Answers by Language