faker

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2008-03-30 02:56:12'

与世无争的帅哥 提交于 2019-12-19 04:19:20
问题 System Local PHP 5.6.19 App made with Laravel 5.0, using fzaninotto/Faker as seeder Mysql remote Remote MySQL Debian 8 with MariaDB 10.1.13-MariaDB-1~jessie Running seeder php artisan migrate:reset; php artisan migrate; php artisan db:seed After seeder add an indeterminate number of users (different each time the reproduction of the error) get error: [Illuminate\Database\QueryException] SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2008-03-30 02:56:12' for column

NameError: uninitialized constant Faker

旧街凉风 提交于 2019-12-18 14:11:53
问题 I am trying to run a simple bundle exec rake db:seed for my database in Rails 4. However, when running it, I get the following output: ********-C02MGBVJFD57:myapp ***********$ bundle exec rake db:seed Your Gemfile lists the gem factory_girl_rails (>= 0) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later. rake aborted! NameError: uninitialized constant Faker /Users/**********

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

只谈情不闲聊 提交于 2019-12-12 08:35:14
问题 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 which involve foreign keys and table relationships : One to One One to Many Many to Many ...Like the one described in the link: Laravel 5.1 foreign keys in model factory. In this topic, the official documentation suggests to run the database seeds

Rake aborted Uploading images using faker for ruby project

久未见 提交于 2019-12-12 00:40:20
问题 I am following a Ruby on Rails guide and ran into a problem generating fake content using the gem "Faker". I installed faker and followed the instructions to populate users and photos into my project. I created this file in lib/tasks/populate.rake lib/tasks/populate.rake namespace :db do desc "Fill database with sample data" task populate: :environment do 10.times do |n| puts "[DEBUG] creating user #{n+1} of 10" name = Faker::Name.name email = "user-#{n+1}@example.com" password = "password"

Laravel 5.1 foreign keys in model factory

孤街醉人 提交于 2019-12-10 13:10:00
问题 How do you define foreign keys in a model factory. For example if I have a organisations table which has a foreign key to the countries table, in my model factory I'm having to define a dummy value for the country id as follows: $factory->define(App\Organisation::class, function ($faker) { return [ 'name' => $faker->company, 'country_id' => 197, ]; }); In my organisations table seeder class I am doing the following but the faker object isn't present - do I need to create a new faker object in

Should we be using Faker in Rails Factories?

拈花ヽ惹草 提交于 2019-12-10 12:53:17
问题 I love Faker, I use it in my seeds.rb all the time to populate my dev environment with real-ish looking data. I've also just started using Factory Girl which also saves a lot of time - but when i sleuth around the web for code examples I don't see much evidence of people combining the two. Q. Is there a good reason why people don't use faker in a factory? My feeling is that by doing so I'd increase the robustness of my tests by seeding random - but predictable - data each time, which

Faker "Don't Know How to Build Task?

≯℡__Kan透↙ 提交于 2019-12-10 11:57:13
问题 I checked out the questions that have already been asked on this subject, "There are many", but I do not find a solution. I have a fairly large task and the files name is 'sample_employee_data.rake'... so here goes: namespace :db do desc "Fill database with sample Employee data" task populate: :environment do @gender = ["Male", "Female"] @role = ["Staff", "Support", "Team_Leader", "Manager", "Director"] @marital_status = ["Single", "Married"] @primary_position = ["Household", "Job Developer",

How to implement your own Faker provider in Laravel

ぃ、小莉子 提交于 2019-12-09 09:46:42
问题 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? 回答1: You should use php artisan to generate the custom provider... On the command line, navigate to the root of your app and type... php artisan make:provider FakerServiceProvider That should generate a new provider in the app/Providers folder. Here is what my register function looks like going off the example in the faker

Robot framework: Using faker to generate a prefix string for account data

守給你的承諾、 提交于 2019-12-08 09:35:15
问题 I'm writing test cases that test the functionality of adding an account. This means that I need to generate data for the Account's: Name, email, reference no and order no. I was thinking that for each of these fields I could just generate a random word or number with a prefix so that I can use a script to delete these entries from the database regularly. The issue is, I'm not sure how to add prefixes or indeed just use most of faker's keywords. At the minute I'm using the md5 keyword to

Laravel, Faker - Increment generated dateTime

依然范特西╮ 提交于 2019-12-06 10:45:33
问题 I'm using Faker package in my Seeder to generate fake data for training events. Each event has starts_at and ends_at fields. I want to populate the ends_at field with a DateTime that is after the one generated for starts_at , preferably by 1 to 8 hours, or even a fixed 1 hour difference would be fine. 回答1: here is an easy way to define the ends_at $starts_at = Carbon::createFromTimestamp($faker->dateTimeBetween($startDate = '+2 days', $endDate = '+1 week')->getTimeStamp()) ; $ends_at= Carbon: