Questions tagged [faker]

An extension or library used in certain programming languages or frameworks (namely Ruby or Yii2) for generating fake data for debug purposes and testing.

In Ruby, Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.

In Yii2, Faker can generate random strings (like name, address, phone number or anything), random numbers, keys or harshes as well as long sentences of fake text. It can be accessed in OOP style.

A PHP library is available for Faker that is used in some frameworks such as Laravel.

703 questions
67
votes
5 answers

Faker.js random number between 2 values

This one is driving me a little mad, I'm sure it's simple but it doesn't seem to be documented anywhere. Im using Faker.js and the following to generate my random number: faker.random.number(); Works great, now if I want to do it between 2 numbers,…
K20GH
  • 6,032
  • 20
  • 78
  • 118
50
votes
6 answers

Laravel - Seeding Many-to-Many Relationship

I have a users table and a roles table that has a many-to-many relationship. These two tables are connected to a junction table called role_user. This is a model of the tables and its connections. Below are the Models in my Laravel…
Bilal Khawar
  • 511
  • 1
  • 4
  • 7
49
votes
5 answers

How to Generate Random String using Laravel Faker?

is there any way or method to generate fake string using laravel faker ? like in laravel we generate string upto 20 chars.. str_random(20);
Vishal
  • 611
  • 1
  • 8
  • 8
39
votes
4 answers

What happened with faker.js

I am seeing the repo is completely blank with a message saying What really happened with Aaron Swartz? I am wondering if it is still safe to keep using it or we should switch to another alternative. Here is the link to the repo…
Rene Enriquez
  • 1,418
  • 1
  • 13
  • 33
38
votes
2 answers

FactoryGirl + Faker - same data being generated for every object in db seed data

I am using FactoryGirl and Faker to generate user objects in my seeds.rb file but for some reason the exact same user is being created and rake db:seed is failing because of an email uniqueness validation. Factory for users: #users.rb require…
sixty4bit
  • 7,422
  • 7
  • 33
  • 57
37
votes
5 answers

How to use Faker from Factory_boy

Factory_boy uses fake-factory (Faker) to generate random values, I would like to generate some random values in my Django tests using Faker directly. Factory_boy docs suggests using factory.Faker and its provider as : class…
marcanuy
  • 23,118
  • 9
  • 64
  • 113
27
votes
4 answers

How to get future date in Faker

How do I get future dates with: https://github.com/fzaninotto/Faker#fakerproviderdatetime dateTime($max = 'now') i.e. what should the $max value be for datetime in the future
Angad Dubey
  • 5,067
  • 7
  • 30
  • 51
24
votes
3 answers

Defining Laravel foreign keys with Model Factories, One to One & One to Many Relationships without creating unnecessary models

Recently I have been trying to seed my database using Laravel seeding through Model Factories and Faker. For simple schemas, it is just a breeze to have it working :). However, I have encountered several problems when working with complex DB schemas…
andcl
  • 3,342
  • 7
  • 33
  • 61
22
votes
2 answers

How to use faker.js in typescript?

As in topic. I cannot handle it :/ I've installed npm i faker and also npm i @types/faker --save-dev my IDE found fakerStatic.name.findName() but browser not recognizes fakerStatic. import 'faker'; does not help.
piernik
  • 3,507
  • 3
  • 42
  • 84
22
votes
3 answers

Populate Django database

I'm developing a Django application which stores user information like their address, phone number, name, etc. I've worked with PHP's Faker library and the seeder included with Laravel. I had been able to populate the database with fake data but now…
user3186459
  • 417
  • 1
  • 4
  • 12
18
votes
5 answers

How can I declare $faker in the seed file in Laravel when overriding for argument to factory?

I am trying to create multiple model of seeds like seedt1, seedt2, seedt3 with parameters for the sample. I am aware of factory states. I don't want to use it, I want to keep my factory model minimal and clean as possible. I have my model…
Lisendra
  • 183
  • 1
  • 1
  • 5
17
votes
5 answers

How to implement your own Faker provider in Laravel

I want to create a custom provider for Faker in Laravel (e.g. one for a random building name). Where do I store the custom provider in my application and how do I use it?
carte
  • 1,033
  • 2
  • 13
  • 29
16
votes
2 answers

How to get a city inside a specific country with Faker

I'm working with the Faker extension in Laravel 5 to populate my database. I have "countries" and "Cities" tables so I called $faker->country but how can I get a city that is inside that country? I don't want "Bogotá" to belong to "EEUU".
Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115
15
votes
6 answers

Laravel Faker Unknown formatter

I have tried everything possible but I could not get to the bottom of what I am doing wrong. I am trying to load my database with dummy data but I keep get unknown formatter "description". Description is one of the variables I am using. Below is my…
olasammy
  • 6,676
  • 4
  • 26
  • 32
15
votes
2 answers

How to handle foreign key in FactoryGirl

I have a user model and a follower model, such that a user can have many followers. So in schema of follower model I have user_id column and a follower_by_user_id column. So in follower model a user can be followed by many followers. User id's are…
Geek_Akash
  • 189
  • 1
  • 11
1
2 3
46 47