All Projects → Naoray → Laravel Factory Prefill

Naoray / Laravel Factory Prefill

Licence: mit
Prefills factories with faker method suggestions to increase productivity

Projects that are alternatives of or similar to Laravel Factory Prefill

Laravel Ownership
Laravel Ownership simplify management of Eloquent model's owner.
Stars: ✭ 71 (-31.73%)
Mutual labels:  laravel, package
Laravel Mixpanel
Intuitive drop-in analytics.
Stars: ✭ 80 (-23.08%)
Mutual labels:  laravel, package
Env Providers
👷 Load Laravel service providers based on your application's environment.
Stars: ✭ 73 (-29.81%)
Mutual labels:  laravel, package
Watchable
Enable users to watch various models in your application.
Stars: ✭ 65 (-37.5%)
Mutual labels:  laravel, package
Laravel Analytics
Analytics for the Laravel framework.
Stars: ✭ 91 (-12.5%)
Mutual labels:  laravel, package
Laravel Mentions
End-to-end mentions in Laravel 5.
Stars: ✭ 68 (-34.62%)
Mutual labels:  laravel, package
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-24.04%)
Mutual labels:  laravel, package
Laravel Packager
A cli tool for creating Laravel packages
Stars: ✭ 1,049 (+908.65%)
Mutual labels:  laravel, package
Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+1149.04%)
Mutual labels:  laravel, package
Laravel Package Maker
Get a 📦 skeleton and all other `make` commands from laravel base for package development.
Stars: ✭ 89 (-14.42%)
Mutual labels:  laravel, package
Laravel Packme
A CLI starter pack for developing a package with Laravel 5
Stars: ✭ 64 (-38.46%)
Mutual labels:  laravel, package
Flex Env
🌳 Manage your .env file in Laravel projects through artisan
Stars: ✭ 95 (-8.65%)
Mutual labels:  laravel, package
Shield
The core shield package.
Stars: ✭ 60 (-42.31%)
Mutual labels:  laravel, package
Picasso
Laravel Image Management and Optimization Package
Stars: ✭ 70 (-32.69%)
Mutual labels:  laravel, package
Laravel Reviewable
Adds a reviewable feature to your laravel app.
Stars: ✭ 57 (-45.19%)
Mutual labels:  laravel, package
Manager
Implementation of the Manager pattern existing in Laravel framework
Stars: ✭ 74 (-28.85%)
Mutual labels:  laravel, package
Htmlcache
Laravel middleware to cache the rendered html
Stars: ✭ 35 (-66.35%)
Mutual labels:  laravel, package
Laravel Dropbox Driver
A storage extension for Dropbox.
Stars: ✭ 42 (-59.62%)
Mutual labels:  laravel, package
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-15.38%)
Mutual labels:  laravel, package
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-8.65%)
Mutual labels:  laravel, package

laravel-factory-prefill

Software License Total Downloads Build Status

This repository has been archived! Use Shift's Factory Generator to utilize the new class factories of Laravel 8.

Factories are a great concept and I really love to use them for testing purposes, but it sucks to write every needed column name and associated faker methods by hand. This package aims to make the process less painful by providing a command to prefill your factories!

After creating a factory with the artisan cli you end up having something like this:

<?php

use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
    return [
        //
    ];
});

With laravel-factory-prefill you can just skip the previous command call and instead execute php artisan factory:prefill Habit.

factory:prefill

Install

composer require naoray/laravel-factory-prefill --dev

Usage

After running php artisan migrate you are good to go. If you want the factory:prefill command to notice the model relations, you should implement the methods first!

Tip: If you also want the realtionships to be loaded automatically, you have to define the methods in the models.

Fill all Factories

To generate factories for all models run

php artisan factory:all

Models in different directories

To prefill factories from models outside of the app/ directory just add the -P flag and provide the path.

php artisan factory:all --path=Some/Other/Path

you can also append the --realpath option to indicate that the given path is a pre-resolved absolut path.

Fill single Factory

To fill a single factory you can either run php artisan factory:prefill model_name or php artisan factory:all model_name.

Models with different namespace

To prefill factories from models outside of the App/ namespace just add the -O flag and provide the full path in the model name.

php artisan factory:prefill "Some\Other\Namespace\ModelName" -O

Nullable columns

By default nullable columns are ignored. If you want to also add nullable columns to your factory includ the flag -N or --allow-nullable.

php artisan factory:prefill ModelName -N or php artisan factory:all -N

Testing

Run the tests with:

vendor/bin/phpunit

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].