Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Artisan Factory Create Command #4

Merged
merged 9 commits into from
Jun 26, 2024

Conversation

mehedijaman
Copy link
Contributor

@mehedijaman mehedijaman commented Jun 7, 2024

This PR introduces the artisan command of "php artisan modular:make-factory ModuleName FactoryName" command.

For example: "php artisan modular:make-factory Product ProductCategory". This will create a factory blueprint in "ModuleName/Database/Factories/ProductCategoryFactory.php".

The Factory code will be as follows:

<?php
namespace Modules\Product\Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Modules\Product\Models\ProductCategory;

class ProductCategoryFactory extends Factory
{
    protected $model = ProductCategory::class;

    public function definition(): array
    {
        //$name = $this->faker->unique()->sentence(4);

        return [
            //'name' => $name,            
            
            //'created_at' => $this->faker->dateTimeBetween('-1 year', '-6 month'),
            //'updated_at' => $this->faker->dateTimeBetween('-5 month', 'now'),
        ];
    }
}

The Factory will also be created while creating a brand new module.

@daniel-cintra
Copy link
Collaborator

Hi Mehedi!

Thank you for your time in this Pull Request. Please don't forget to follow these topics listed in the contribution guidelines:

Coding Standard - To format the PHP code run ./vendor/bin/pint.

Add tests! - Please always provide tests.

Completing these steps, we can proceed with the Pull Request.

Thank you!

Copy link
Collaborator

@daniel-cintra daniel-cintra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please check the highlighted blocks.

Copy link
Collaborator

@daniel-cintra daniel-cintra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@daniel-cintra daniel-cintra merged commit 1c3ae40 into ModularThink:main Jun 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants