Giter Club home page Giter Club logo

blueprint's Introduction

Build Status Latest Stable Version License

Blueprint

Blueprint is an open-source tool for rapidly generating multiple Laravel components from a single, human readable definition.

Watch a quick demo of Blueprint in action or continue reading to get started.

Requirements

Blueprint requires a Laravel application running the latest stable release of Laravel, currently Laravel 10.x.

Installation

You can install Blueprint via Composer using the following command:

composer require -W --dev laravel-shift/blueprint

Blueprint will automatically register itself using package discovery.

If you wish to run the tests generated by Blueprint, you should also install the Additional Assertions package:

composer require --dev jasonmccreary/laravel-test-assertions

Basic Usage

Blueprint comes with a set of artisan commands. The one you'll use to generate the Laravel components is the blueprint:build command:

php artisan blueprint:build [draft]

The draft file contains a definition of the components to generate. Let's review the following example draft file which generates some blog components:

models:
  Post:
    title: string:400
    content: longtext
    published_at: nullable timestamp
    author_id: id:user

controllers:
  Post:
    index:
      query: all
      render: post.index with:posts

    store:
      validate: title, content, author_id
      save: post
      send: ReviewPost to:post.author.email with:post
      dispatch: SyncMedia with:post
      fire: NewPost with:post
      flash: post.title
      redirect: posts.index

From these 20 lines of YAML, Blueprint will generate all of the following Laravel components:

  • A model class for Post complete with fillable, casts, and dates properties, as well as relationships methods.
  • A migration to create the posts table.
  • A factory intelligently setting columns with fake data.
  • A controller class for PostController with index and store actions complete with code generated for each statement.
  • Routes for the PostController actions.
  • A form request of StorePostRequest validating title and content based on the Post model definition.
  • A mailable class for ReviewPost complete with a post property set through the constructor.
  • A job class for SyncMedia complete with a post property set through the constructor.
  • An event class for NewPost complete with a post property set through the constructor.
  • A Blade template of post/index.blade.php rendered by PostController@index.
  • An HTTP Test for the PostController.
  • A unit test for the StorePostRequest form request.

Note: This example assumes features within a default Laravel application such as the User model and app.blade.php layout. Otherwise, the generated tests may have failures.

Documentation

Browse the Blueprint Docs for full details on defining models, defining controllers, advanced configuration, and extending Blueprint.

Support Policy

Starting with version 2, Blueprint only generates code for the latest stable version of Laravel (currently Laravel 10). If you need to support older versions of Laravel, you may use version 1 or upgrade your application (try using Shift).

Blueprint still follows semantic versioning. However, it does so with respect to its grammar. Any changes to the grammar will increase its major version number. Otherwise, minor version number increases will contain new features. This includes generating code for future versions of Laravel.

blueprint's People

Contributors

adevade avatar axit-joost avatar benjam-es avatar bingtsingw avatar devmsh avatar diogogomeswww avatar dmason30 avatar faustbrian avatar ghostwriter avatar jasonmccreary avatar justinwhite15 avatar jyrkidn avatar laravel-shift avatar matt-h avatar naoray avatar pr3d4dor avatar promatik avatar pxpm avatar rafapaulino avatar raymadrona avatar rcrosbourne avatar rhynodesigns avatar ryangjchandler avatar ryanpricedotca avatar sajaddp avatar skylerkatz avatar spaceemotion avatar spekulatius avatar wowenko avatar yannikfirre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blueprint's Issues

Support precision in factory faker data

When providing a precision for float or decimal columns, it would be ideal if this precision were passed as the first argument to Faker's randomFloat method

Even better if the max digit were inferred as well.

For example the model-modifiers.bp fixture defines: total: decimal:10,2.

The generated is factory has: 'total' => $faker->randomFloat().

Ideally it would generate: 'total' => $faker->randomFloat(2) or even 'total' => $faker->randomFloat(2, 0, 999999)

Idea: config/blueprint.php in which you can define output paths

Some folks really dislike Laravel's default locations for generated output. A common occurrence is that folks might want to output models to app/Models instead of directly under app/. There are also others (myself included) that attempt to do some Domain separation of the business logic (not entirely DDD, but at least some sort of other structure).

Whilst tools like PhpStorm pack enough firepower to easily refactor the output, I still think it might be a good idea to at least configure some paths for the generator to output to? Love to read your take on this idea.

Undo previously built components

While it's easy to use a clean working state and version control to manage the generation of new components, it would be better if Blueprint had an "undo" command to revert/remove the generated components of the last built.

Generate model relationships

Model definitions which include foreign keys (e.g. *_id: id) should also generate for the relationship in the Model and a new, related record in the Factory.

Build out Rules translator

While sufficient to past the current tests, the Rules translator is incomplete.

Given a Column definition, the Rules translator should be have the information it needs to intelligently translate this data into validation rules.

It can do so by:

  • Column name (e.g. email or email_address adds an email validation rule)
  • Relationship (e.g. user_id adds an exists validation rule with proper attributes)
  • Data Type (e.g. integer)
  • Attributes (e.g. max lengths, digits precision,in set, etc)
  • Modifiers (e.g. gt:0 for unsigned, unique, etc)

I expect this will constantly be tweaked. I plan to finish a base version for v1.0.

Nonetheless, I welcome PRs to begin any portion of the items above. However, large or small. I only ask that you add to the test.

To help get started, you can review the current implementation and review the available validation rules to get ideas of the types of things that can be translated.

Table without a model

I cannot currently see any functionality to add a table without a model, thus when trying to replicate the default laravel auth system, we have to create a full model and factory for the password_resets table rather than just the existing migration.

Bug: Failed to open stream NewPost.php

Using the example yaml from the README, when I use php artisan blueprint:build I get an error:

ErrorException : file_put_contents(app/Events/NewPost.php): failed to open stream: No such file or directory

(Laravel v6.6.0, PHP 7.4.0, Mac 10.14.6 (18G1012))

Details
ErrorException  : file_put_contents(app/Events/NewPost.php): failed to open stream: No such file or directory

  at /Users/martin/Sites/blueprint-05/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133
    129|      * @return int|bool
    130|      */
    131|     public function put($path, $contents, $lock = false)
    132|     {
  > 133|         return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    134|     }
    135|
    136|     /**
    137|      * Write the contents of a file, replacing it atomically if it already exists.

  Exception trace:

  1   file_put_contents("app/Events/NewPost.php", "<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;

class NewPost
{
    use SerializesModels;

    public $post;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($post)
    {
        $this->post = $post;
    }
}
")
      /Users/martin/Sites/blueprint-05/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133

  2   Illuminate\Filesystem\Filesystem::put("app/Events/NewPost.php", "<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;

class NewPost
{
    use SerializesModels;

    public $post;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($post)
    {
        $this->post = $post;
    }
}
")
      /Users/martin/Sites/blueprint-05/vendor/laravel-shift/blueprint/src/Generators/Statements/EventGenerator.php:46

  Please use the argument -v to see more details.

[BUG] Adding Softdeletes

  1. Adding softDeletes in yaml adds 'softDeletes' => $faker->word, inside factory

Steps to reproduce

models:
  Post:
    title: string:400
    content: longtext
    published_at: nullable timestamp
    softDeletes: true

Erase command error and rerun

The erase command has two bugs:

  1. It errors when previous models were created
  2. After running, it still stores the previously built files

Ability to create SoftDeletes Column and TimeStamps Columns with Timezone

It would be helpful to be able to add those columns with the timezone.

  1. $table->timestampsTz(); Adds nullable created_at and updated_at TIMESTAMP (with timezone) equivalent columns.
  2. $table->softDeletesTz(); Adds a nullable deleted_at TIMESTAMP (with timezone) equivalent column for soft deletes.

Support for Custom Namespace

In most of the time Every Devs prefers to keep the models and Controllers based on their groups
So For Example i have a app that contains the Blog so i wish to keep the Models inside the app/Models/Blog so this below syntax might be helpful in many situation because i see most of the app that is Built with laravel has the models inside the app/Models Directory

models:
  Models/Blog/Post:
    title: string:400
    content: longtext
    published_at: nullable timestamp

controllers:
  Blog/PostController:
    index:
      query: all posts
      render: post.index with posts

    store:
      validate: title, content
      save: post
      send: ReviewNotification to post.author
      queue: SyncMedia
      flash: post.title
      redirect: post.index

Model relationship definitions should add foreignKey argument

Example input:

  Person:
    additionalName: string
    award: string
    birthDate: date
    birthPlace_id: id:place
    callSign: string
    deathDate: date
    deathPlace_id: id:place

Should render:

// \App\Person::class
// ...
    public function birthPlace()
    {
        return $this->belongsTo(\App\Place::class, 'birthPlace_id');
    }

    public function deathPlace()
    {
        return $this->belongsTo(\App\Place::class, 'deathPlace_id');
    }

Generate comments to help educate new uses of design choices

Both Laravel and Blueprint follow some documented, as well as community, conventions. Developers new to Laravel may not be familiar with these.

As such, it'd be nice to have a --notes option which would add the Laravel-style block comments with more information about the generated code with links to the documentation where applicable.

With this we can ensure Blueprint users become familiar with Laravel as well as Blueprint, and vice version.

Load existing models

Ideally Blueprint could load existing models to have more context to use as reference when defining controllers.

I like the command name trace for this...

SoftDeletes with Relationships

when SoftDeletes are enabled and relationships exist in the model, then use SoftDeletes; is also added for each function (invalid php code).

Attach relationships to models in factory definitions

As per the Laravel documentation located at https://laravel.com/docs/master/database-testing#relationships, paragraph "Relations & Attribute Closures".

Given the following draft.yaml, modelled after a schema.org/Person:

models:
  Country:
    name: string
    isoAlpha2: string:2
    isoAlpha3: string:3
  ContactPoint:
    contactType: string
    email: string
    faxNumber: string
    telephone: string
  PostalAddress:
    country_id: id:country
    addressLocality: string
    addressRegion: string
    postalOfficeBoxNumber: string
    postalCode: string
    streetAddress: text
    contact_point_id: id:contact_point
  Person:
    additionalName: string
    address_id: id:postal_address
    familyName: string
    givenName: string

The generated factories will currently insert a $faker->randomDigitNotNull, like so:

$factory->define(Person::class, function (Faker $faker) {
    return [
        'additionalName' => $faker->word,
        'address_id' => $faker->randomDigitNotNull,
        'familyName' => $faker->word,
        'givenName' => $faker->word,
    ];
});

As per the documentation, it could be generated like so:

$factory->define(Person::class, function (Faker $faker) {
    return [
        'additionalName' => $faker->word,
        'address_id' => factory(App\PostalAddress::class),
        'familyName' => $faker->word,
        'givenName' => $faker->word,
    ];
});

Subsequently, the other PostalAddressFactory could be like so:

$factory->define(PostalAddress::class, function (Faker $faker) {
    return [
        'country_id' => factory(App\Country::class),
        'addressLocality' => $faker->city,
        'addressRegion' => $faker->state,
        'postalOfficeBoxNumber' => $faker->randomNumber(4),
        'postalCode' => $faker->postcode,
        'streetAddress' => $faker->streetAddress,
        'contact_point_id' => factory(App\ContactPoint::class),
    ];
});

The benefit of this, is that when using the PersonFactory in a test, you will get a Person with a full set of related data:

factory(App\Person::class, 100)->create();
App\Person::with('address.country', 'address.contactPoint')->first();

could yield:

> App\Person {#1062
     id: 1,
     additionalName: "Serena",
     address_id: 1,
     familyName: "Medhurst",
     givenName: "Andreane",
     created_at: "2019-12-06 15:13:14",
     updated_at: "2019-12-06 15:13:14",
     address: App\PostalAddress {#1042
       id: 1,
       country_id: 1,
       addressLocality: "Daniellaville",
       addressRegion: "Texas",
       postalOfficeBoxNumber: "6424",
       postalCode: "68138",
       streetAddress: "65044 Gutkowski Heights Apt. 741",
       contact_point_id: 1,
       created_at: "2019-12-06 15:13:14",
       updated_at: "2019-12-06 15:13:14",
       country: App\Country {#1018
         id: 1,
         name: "Canada",
         isoAlpha2: "PF",
         isoAlpha3: "GRL",
         created_at: "2019-12-06 15:13:14",
         updated_at: "2019-12-06 15:13:14",
       },
       contactPoint: App\ContactPoint {#1026
         id: 1,
         contactType: "Logistics",
         email: "[email protected]",
         faxNumber: "941-910-7739 x572",
         telephone: "1-368-817-4568",
         created_at: "2019-12-06 15:13:14",
         updated_at: "2019-12-06 15:13:14",
       },
     },
   }

Idea: type hint faked in draft.yaml

Here's an idea to 'type hint' the fakes in the draft.yaml

models:
  Country:
    name: string fake:country
    isoAlpha2: string:2 fake:countryCode
    isoAlpha3: string:3 fake:countryISOAlpha3
  ContactPoint:
    contactType: string fake:randomElement['Procurement', 'Sales', 'Logistics', 'Planning', 'HR', 'Helpdesk', 'PR']
    email: string fake:email
    faxNumber: string fake:phoneNumber
    telephone: string fake:phoneNumber
  PostalAddress:
    country_id: id:country
    addressLocality: string fake:city
    addressRegion: string fake:state
    postalOfficeBoxNumber: string fake:randomNumber(4)
    postalCode: string fake:postcode
    streetAddress: text fake:streetAddress
    contact_point_id: id:contact_point
  Person:
    additionalName: string fake:firstName
    address_id: id:postal_address
    familyName: string fake:lastName
    givenName: string fake:firstName

Make the draft.yaml file generate basic auth framework with a flag

Just had a thought about this while i was using it -

Would it be worth having draft.yaml able to generated with the basic auth framework for a user (Users Table and password_resets table) as an example of how to use Blueprint, this could be a good reference for users just starting to use blueprint.

This could be an option flag i.e. -auth on the command.

Feature request: reverse engineering

First thanks for this amazing tool!!!

Idea:
Sometimes we have projects that are 80% similar (data / workflow) to something else we built in the past, it would be really cool if we can do the following:

  • have a blueprint file reverse-engineered from an existing project
  • import it to the new project
  • change the 20% that is different and bootup the new project that way.

Nova Resource

It would be great if blueprints generate Nova resources as will

Early logo ideas

Just two rough logo ideas for Blueprint.
Probably not more than just some inspiration or base for discussion as they're just the obvious and super simple.

Blueprint-01

Blueprint-02

Idea: Policy generation & Authorisation

It would be great if policy generation was possible, maybe as config associated to the model definition? Perhaps even just calling php artisan make:policy {Model}Policy --model={Model}

Optimize column datatypes

When defining models it would be good to optimize any column data types and modifiers.

For example, the definition column: integer unsigned currently generates $table->integer('column')->unsigned(), but could be optimized to generate $table->unsignedInteger('column').

Additional optimizations can be inferred from the list of available data types.

Support `id` column data type for Laravel 7

This adds support of the id shorthand column type added in Laravel 7.

Since Blueprint will continue to support back to Laravel 6 (LTS) for a while, this should only do so for apps running Laravel 7 or higher.

Migration filenames require sequence number

Given the following draft.yaml which is modeled after a schema.org/Person:

models:
  Country:
    name: string
    isoAlpha2: string:2
    isoAlpha3: string:3
  ContactPoint:
    contactType: string
    email: string
    faxNumber: string
    telephone: string
  PostalAddress:
    country_id: id:country
    addressLocality: string
    addressRegion: string
    postalOfficeBoxNumber: string
    postalCode: string
    streetAddress: text
    contact_point_id: id:contact_point
  Person:
    additionalName: string
    address_id: id:postal_address
    familyName: string
    givenName: string

When running blueprint:build, it will yield migrations that do not have foreign key constraints for the related items.

Additionally: if the migrations would have had foreign key constraints, there would have been issues: the generated migrations all share the same timestamp in the filename, which means that they will be processed in alphabetical order, which will create a people table, before the postal_addresses table and therefore referencing a table that does not yet exists.

Example:

$ ls -1 database/migrations
...
2019_12_06_142421_create_contact_points_table.php
2019_12_06_142421_create_countries_table.php
2019_12_06_142421_create_people_table.php
2019_12_06_142421_create_postal_addresses_table.php

The order of the models: section was deliberate to make sure that the blueprint:build would generate in the correct order. However, since all of the generation occurred within the same second, the generated files fall back into alphabetical ordering.

So, implementing this would also require adding some kind of sequence numbering in the filename.

Class names getting cut-off in factory

The generator that attaches relationships to models us cutting off the last 3 letters of the class. Traced it to this PR: #36

Issue is on this line:

$name = Str::substr($column->name(), 0, -3);

It results in code that looks something like this (you can see each is missing characters at the end):

        'department' => factory(\App\Departm::class),
        'supervisor' => factory(\App\Supervi::class),
        'comments' => $faker->,
        'organization' => factory(\App\Organizat::class),
        'campus' => factory(\App\Cam::class),
        'building' => factory(\App\Build::class),

I wanted to post it as an issue to make sure I wasn't doing something wrong. I can't see why the column name is being cut here.

Exclude `nullable` columns from model factories

In retrospect filling fake data for nullable columns seems to be too explicit. Often these columns should be left undefined in the default factory and instead defined in a factory state.

This is open for discussion as it would be a breaking change based on original behavior.

Make Blueprint class extensible

While the Blueprint class has methods to register additional lexers and generators it is created within the command and as such not readily extensible.

Potential options:

  • resolved as a singleton to share the same object with other components
  • allow publishing of a configuration file to register additional functionality

Split faker generation to registry package

The translation used by Blueprint is also used by the Model Factory Generator. I envision other packages benefiting from this data and as such would like to separate it to its own package and include it as a dependency.

error about tests/Feature/Http/Controllers

i'm using this pacakge from awhile and it's excellent but after adding testing generators support it gives me an error about not found tests/Feature/Http/Controllers beucase it's not exist by default

A question to the maintainer

Hey, thank you for your awesome work on blueprint it does wanders.

I've made some uuid and API resources work in my fork and was wandering do you want those changes in upstream?
(https://github.com/tectiv3/blueprint/tree/add-api-resources-support)
I can separate uuids, resources generation and foreign keys and indexes support into different PRs if you are interested.
Currently I've added support for uuid and json columns, index modifiers, api controllers, policies, resources generation and foreign keys in migrations.

models:
  Order:
    id: uuid primary
    user_id: id foreign:user
    external_id: string nullable index
    subscription_id: uuid foreign:subscription
    sku: string nullable
    status: enum:created,pending,paid,deleted,refunded default:'created'
    expires_at: timestamp nullable index
    meta: json default:'[]'
controllers:
  Order:
    index:
      query: user.all
      resource: order collection:paginate
    store:
      validate: type, name
      save: order
      fire: NewOrder with:order
      resource: order
    show:
      authorize: order
      resource: order
    destroy:
      authorize: order
      delete: order
      resource: empty
  Subscription:
    resource: api
    index:
      query: user.all
      resource: subscription collection:paginate

Once again, thank you for creating this tool!

Notification Vs Mail

I see a stament

send: ReviewNotification to post.author

Which means that it need to Create a Notification class

send: ReviewMail to post.author

Which means that it need to Create a Mail class

FormRequestGenerator - Syntax to add additional rules; understand relationships and add 'exists'

If you create a User model and a Messages model, if "user_id" is a field in the SendMessagesRequest validator, it should be able to detect that "User" is an existing model, and require that the ID already exists in the "users" table.

Also, for the "validate:" line, there should be some kind of mark (I've used "(*)" in the example below, but it could be anything) that will tell the FormRequestGenerator to make the field unique.

For example:

models:
  Post:
    title: string:400
    content: longtext
    published_at: nullable timestamp

controllers:
  Post:
    index:
      query: all
      render: post.index with:posts

    store:
      validate: title(*), content

Thoughts?

Add `between` rule for decimal or float columns

When a "decimal" column is defined with precision and decimal attributes it would be possible to add a between rule.

For example, given the definition:

total: decimal:10,2

Blueprint could add between to generate the following rule:

'decimal' => 'required|numeric|between:0,999999.99'

Generate routes

Based on the controller definition, routes should also be generated. It would be nice if these routes were properly optimized as a resource where applicable.

Allow `uuid` shorthand and automatic primary key

While uuid column types are support, they are currently a bit verbose to define.

It would be nice instead of the current definition of id: uuid primary, to be able to simply use a shorthand of uuid that would expand to id: uuid

This implies the use of the primary modifier if a user were to define id: uuid.

Path to draft.yaml

I have a fresh installation of Laravel with blueprint installation after running the command

php artisan blueprint:build

Illuminate\Contracts\Filesystem\FileNotFoundException  : File does not exist at path draft.yaml

at D:\xampp\htdocs\websockets\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php:52
  48|         if ($this->isFile($path)) {
  49|             return $lock ? $this->sharedGet($path) : file_get_contents($path);
  50|         }
  51| 
> 52|         throw new FileNotFoundException("File does not exist at path {$path}");
  53|     }
  54| 
  55|     /**
  56|      * Get contents of a file with shared access.

Exception trace:

1   Illuminate\Filesystem\Filesystem::get("draft.yaml")
    D:\xampp\htdocs\websockets\vendor\laravel-shift\blueprint\src\BlueprintCommand.php:47

2   Blueprint\BlueprintCommand::handle()
    D:\xampp\htdocs\websockets\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

Please use the argument -v to see more details.

I just want to know where to create the draft.yaml inside the Laravel Application

error about HttpTestAssertions

please include jasonmccreary/laravel-test-assertions package in composer.json of this package because it gives me an error

Generate controller definitions

Before marking a v1.0, Blueprint needs to generate controllers supporting the following actions:

  • validate
  • query
  • save
  • update
  • send
  • queue
  • flash
  • store
  • redirect
  • display

Feature Request: Remember files

I think it would be amazing if a kind of manifest file would be generated in the app store where the generated files of the blueprint are documented.
Later, if we regenerate the blueprint, we override all the files which are having the same hash sums like before, also we should scan the web.php for the occurrence of the lines we want to generate and then we should skip the lines in a given case.

Support changes to existing models

Blueprint only generates new Model components. As such, assumptions have been made about file naming, migration schema, and class existence.

Ideally, Blueprint would also append existing components with new, updated, or removed columns.

Factory failed when type is enum

I create my .yaml file

models:
  Category:
    category_uuid: string:200
    name: string:200
    status: enum:ACTIVE,NONACTIVE
controllers:
  Category:
    index:
      query: all
      render: category.index with:categories
    create:
      render: category.create
    store:
      validate: category_uuid, name, status
      save: category
      flash: category
      redirect: category.index
    update:
      find: category
      redirect: category.index
    show:
      find: category
      render: category.show with:category
    edit:
      find: category
      render: category.edit with:category
    destroy:
      delete: category.id
      redirect: category.index

But when I run, factory file is fail

<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Category;
use Faker\Generator as Faker;

$factory->define(Category::class, function (Faker $faker) {
    return [
        'category_uuid' => $faker->word,
        'name' => $faker->name,
        'status' => $faker->,
    ];
});

As you see, faker for enum is fail. Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.