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 ̵…
Tag: laravel-factory
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. OrderSeede…
Factory creating multiple models with different number of relationships
I’m using the following code to create 20 posts, each of which has 3 comments. Instead I’d like to create 20 posts, each of which has a random number of comments (e.g. post 1 has 2 comments, post 2 has 4 comments, etc.) This did not work, each post had the same (random) number of comments. How can…
Laravel Many-to-Many Factory with custom id type
I am using Laravel 8 and trying to make database factories/seeders I am having some issues. I have the following database Schema: Now I am trying to create factories and database seeders but I get an error using the following line to seed: This gives me the following error: Which is if I understand it correct…