I've this tables in my Laravel app: Users Books Categories book_category Authors author_book
im seeding my table wth this code:
factory(App\User::class, 50)->create()->each(function ($user) {
$user->books()
->create(factory(App\Book::class)->make()->toArray())
->category()
->attach([1,2]);
});
How can I add author too this code for seed? Is there another way?