Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel seeder with relationship

use AppModelsUser;
 
/**
 * Run the database seeders.
 *
 * @return void
 */
public function run()
{
    User::factory()
            ->count(50)
            ->hasPosts(1)
            ->create();
}
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #laravel #seeder #relationship
ADD COMMENT
Topic
Name
5+1 =