I’m working with Laravel 9 and I have used this column at users table for storing user mobile phone number: And at the factor, I tried this to fill out this column: But when I run php artisan db:seed, I get this error: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column ‘usr_mobile_phone’ at row 1
Tag: laravel-seeding
Laravel 9 – Seeder | TypeError array_merge(): Argument #2 must be of type array, int given
I have two tables named Order and OrderItem. While creating data in the Order table, I am trying to enter data into the OrderItem table at the same time. The codes are as follows; OrderSeeder.php OrderFactory.php OrderItemFactory.php Answer When I updated the page like this, the problem was solved. OrderSeeder.php You can use it as a resource when you encounter
Target class [DatabaseSeedersUsersTableSeeder] does not exist
I am getting the error “Target class [DatabaseSeedersUsersTableSeeder] does not exist” and I cannot figure out why. I have already tried solutions posted to similar issues and none of them worked for me. Here is my composer.json autoload/classmap settings UsersTableSeeder class DatabaseSeeder class Answer You are missing namespace in UsersTableSeeder class. This will make autoloader to find the other seeder
How to seed a model that has a relationship to itself
I am using Laravel 8 and PHP v7.4 I have a model with a schema generated with the below migration. CreateContestsTable public function up() { Schema::create(‘contests’, function (Blueprint $table) …
laravel seeder is giving an error and won’t seed
I’ve been trying to get my seeder to work but it keeps giving me the following error Call to undefined function DatabaseSeedersfactory() at database/seeders/ContactTableSeeder.php:16 12▕ …
Laravel eloquent multiple belongsTo seeding
I have three models, User, Category and Article. Article belongs to both a User and a Category where the foreign keys user_id and category_id are not null. Am lost trying to seed the database …
laravel seed rollback after seeding database
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. Answer use Undo Seeder for Laravel. When you install UndoSeeder, the following artisan commands are made available: more Undo-Seeder
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?
Laravel seeder for table that is hardcoded
I have several tables in my database that are simply used for reference in my application. For example, a table that has two columns, State and State Abbreviation, and has all 50 states and their abbreviations as rows. I want to write seeders for these tables in Laravel, since I want these tables to exist when I start a new