How to generate a column data depend on other column data
Author: abhimanusharmaCreated Jun 26, 2020Updated Sep 24, 2020
Summary
I am trying to insert a record, for example, Total runs and highest scores. In this case, total runs can not be less than highest scores.
Versions
| Version | |
|---|---|
| PHP | 7.3.0 |
fzaninotto/faker |
^1.9 |
use Faker\Generator as Faker;
$factory->define(App\Player::class, function (Faker $faker) {
return [
'total_runs' => $faker->randomNumber(4),
'highest_scores' => $faker->randomNumber(3),
];
});Is there a direct method other than this?
$total_runs = $faker->randomNumber(4);
$highest_scores = $faker->randomNumber(3);
if($highest_scores > $total_runs){ $highest_scores = $total_runs - 1;}
return[
'total_runs' => $total_runs,
'highest_scores' => $highest_scores,
];I've tried searching on google and looked in previous issues but could not found anything related to this. Please help.
Source: fzaninotto/Faker