Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Cycle Orm Adapter Laravel Package

wayofdev/laravel-cycle-orm-adapter

View on GitHub
Deep Wiki
Context7

import {Callout} from "nextra-theme-docs"; import ExternalLink from "../../components/external-link";

Seeders

Laravel includes the ability to seed your database with data using seed classes. All seed classes are stored in the database/seeders directory. Same as in Laravel with Eloquent, you can use default Laravel seeders to seed your data into the database, by using CycleORM database factories.

✏️ Writing Seeders

Seeder classes are generated, same as it is in Laravel, using the make:seeder Artisan command. These classes are stored in the database/seeders directory. Seeder classes may have any name you wish, but probably should follow some sensible convention, such as PostSeeder, CommentSeeder, UserSeeder etc.

php artisan make:seeder PostSeeder

⚡️ Using Entity Factories

Best way to use seeders is to use Entity Factories, which is provided by <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-factories">wayofdev/laravel-cycle-orm-factories</ExternalLink>. You can create a factory for each of your entities and use them to seed your database.

In this documentation section we will use examples from Factories documentation page.

For example, let's create 20 posts and 10 comments for each post:

<?php

declare(strict_types=1);

namespace Database\Seeders\Post;

use Illuminate\Database\Seeder;
use Database\Factories\Post\PostFactory;
use Database\Factories\Post\Comment\CommentFactory;
use Database\Factories\User\UserFactory;

final class PostSeeder extends Seeder
{
    public function run(): void
    {
        $author = UserFactory::new()->createOne();
        $posts = PostFactory::new()->withUser($author)->times(20)->create();

        $posts->each(function (Post $post): void {
            CommentFactory::new([
                'post' => $post,
            ])->times(10)->create();
        });
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity