When the modelFactory of laravel generates false data, how to ensure that it will not be duplicated?

problem description

when the modelFactory of laravel generates false data, how to ensure that it will not be duplicated?

the environmental background of the problems and what methods you have tried

through unique Filter, but it didn"t work. Google checked the relevant problems and didn"t find a suitable one

.

related codes

use Faker\Generator as Faker;

$factory->define(App\Models\Tab::class, function (Faker $faker) {

    return [
        "name" => $faker->unique()->randomElement(["", "", "", "", "", "", "", "", "", "", ""]),
        "name_cover" => "http://imgbftv.b0.upaiyun.com/1342/20180515151342_1_45727.jpeg",
        "name_cover_focus" => "http://imgbftv.b0.upaiyun.com/1342/20180515151342_1_45727.jpeg",
        "bg_cover" => "http://imgbftv.b0.upaiyun.com/1342/20180515151342_1_45727.jpeg",
        "operate_type" => $faker->randomElement([0, 1, 2]),
        "status" => $faker->randomElement([0, 1, 2]),
        "operator" => $faker->username,
        "sort" => $faker->unique()->randomDigit,
    ];
});

public function run()
{
    // create tabs and save them to the database
    $tabs = factory(App\Models\Tab::class,8)->create();
}
    

what result do you expect? What is the error message actually seen?

some field data that is expected to be generated is not duplicated, but the current result is

with duplicate data.
Jun.03,2021

say something stupid. No, no, no.

define a fake data literal array aTextContent, and then the interface method adds a list length parameter listLength, such as a list length of 10, inserting the number of 0 to 9 into a new array aRandom, to disrupt the insertion order.

returns for (int itemo when false data is returned; I < listLength; iPP) .aTextContent [aRandom [I]] (pseudo code)


. I think the plug-in has nothing to say about bug,. I changed create to make, and then changed it back, so I got better again for no reason.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35e9c-2b74b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35e9c-2b74b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?