laravel-seeding Questions

5

Solved

I'm new to Laravel and looking for a good way to seed a pivot table using factories. I don't want to use plain seeders. I'll show you the case: I have three tables (users, skills, and user_skill). ...
Souvenir asked 2/10, 2016 at 16:33

6

Solved

I am trying to recreate the database before each test in some PHPUnit test cases. I am using Laravel 5.3. Here is TestCase: class CourseTypesTest extends TestCase { public function setUp() { pa...
Wald asked 22/1, 2017 at 12:14

3

Solved

I do everything by-the-book: Installed fresh Laravel 5.3.9 app (all my non-fresh apps produce the same error) run php artisan make:auth create migrations for a new table `php artisan make:migra...
Pent asked 15/9, 2016 at 23:46

5

I have an observer for my User model. Inside my observer->created event i have some code. public function created(User $user) { sendEmail(); } So, the idea is, when a user is created, the syst...
Galvez asked 18/2, 2021 at 8:7

5

Solved

What is the optimum way of generating gender using faker, having generated a name so that the gender matches the name return [ 'name' => $faker->name, 'email' => $faker->safeEmail,...
Eeg asked 31/3, 2017 at 10:16

6

Solved

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. ...
Papule asked 23/7, 2017 at 19:33

5

Solved

For the following factory definition, the column order needs to be sequential. There is already a column id that is auto-incremented. The first row's order should start at 1 and each additional row...
Monologue asked 8/7, 2017 at 7:29

1

Solved

I'm working on a package for an internal Laravel application and I'm having trouble running a seeder that exists in the package directory. In my package's composer.json file located in packages/ven...
Lawford asked 5/1, 2023 at 19:29

7

Solved

I would like to pass an argument as to define how many records I want to create during database seeding, without having to edit the factory manually. I have tried different variations on php arti...
Lorrainelorrayne asked 27/11, 2019 at 19:32

3

Solved

I've upgraded to Laravel 8, but my custom seeder in a subdirectory is not working. The file is at database/seeders/tests/TestSeeder.php. When I run the command php artisan db:seed --class="Tes...
Fulvia asked 9/12, 2020 at 3:28

2

Solved

I am getting the error "Target class [Database\Seeders\UsersTableSeeder] does not exist" and I cannot figure out why. I have already tried solutions posted to similar issues and none of t...
Alicaalicante asked 15/1, 2021 at 18:8

6

Solved

I have seeded my DB using php artisan db::seed. Is there a way to rollback what I have seeded into my DB? I cannot seem to find any command like php artisan db::seed rollback.
Frigging asked 23/6, 2017 at 20:52

3

Solved

Laravel's seeder runs a variety of Model Events on my models which trigger New Order notification emails, among other things, from the Product::saved() Model Event. This significantly slows down d...
Misguide asked 27/5, 2015 at 20:10

8

I am using Laravel (4.2) I am working on a project with an authentication system. I need to insert a first user into my users table. I would like to do that directly with a sql command (insert int...
Resist asked 20/12, 2015 at 14:31

4

I am trying to clean the test data from my production tables. In simple environment I can write a script to clean the test data but I wonder how can I do the same in laravel migration script I hav...
Fraser asked 8/1, 2016 at 20:59

10

How can I create a database seeder factory for the following configuration? User // create_users_table.php Schema::create('users', function (Blueprint $table) { $table->increments('id'); ......
Demise asked 10/3, 2018 at 4:47

17

Solved

I want to seed database when I use this public function run() { $users = factory(app\User::class, 3)->create(); } Add three user in database but when I use this public function run() {...
Marotta asked 5/4, 2016 at 8:42

5

Solved

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?
Passivism asked 7/7, 2016 at 16:29

3

Solved

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 ...
Unlimber asked 27/11, 2016 at 12:43

5

Solved

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 minim...
Fay asked 3/7, 2020 at 16:19

1

Solved

Is it possible to add a new column, copy some data to this new column and update the data in another column with a Laravel migration? I have a table something like this; id item price 1 Ite...

5

Solved

Introduction What up folks, I got a question about model factories and multiple unique columns: Background I have a model named Image. This model has language support stored in a separate model,...
Hoashis asked 4/4, 2017 at 9:11

2

Solved

For some of my tables, I'd like to insert a fixed amount of rows with specific data. This is my categories factory: $factory->define(Category::class, function (Faker $faker) { return [ [ 'n...
Xylo asked 12/5, 2019 at 14:44

7

Solved

Laravel's documentation recommends using the DatabaseMigrations trait for migrating and rolling back the database between tests. use Illuminate\Foundation\Testing\DatabaseMigrations; class Exampl...
Jarrell asked 20/2, 2017 at 16:52

3

Solved

i have now new structure of my database, but i need to import the old data in the new format. For that reason i want to use the Laravel seeder, but i need somehow to connect to the old database and...
Mounting asked 21/9, 2016 at 21:17

© 2022 - 2025 — McMap. All rights reserved.