Devise\Support\DeviseSeeder::findOrCreateRow PHP Méthode

findOrCreateRow() public méthode

We use the route name as it should be unique. If an row already exists with the same route name we just ignore the insert. We use similiar logic for new page versions. If a page does not have a page version then it will not be available at it's url because we don't show pages unless there is an active page version
public findOrCreateRow ( string $tableName, array $uniqueKeys, array $data, $timestamps = true ) : StdObject
$tableName string
$uniqueKeys array
$data array
Résultat StdObject
    public function findOrCreateRow($tableName, $uniqueKeys, $data, $timestamps = true)
    {
        if (!is_array($data)) {
            dd($tableName, $uniqueKeys, $data);
        }
        // merge in created_at and updated_at timestamps
        $data = $timestamps ? array_merge(['created_at' => new DateTime(), 'updated_at' => new DateTime()], $data) : $data;
        $object = $this->findRow($tableName, $uniqueKeys, $data);
        if (!$object) {
            DB::table($tableName)->insert($data);
            $object = $this->findRow($tableName, $uniqueKeys, $data);
        }
        return $object;
    }