A code generation tool for Laravel developers.

Related tags

Laravel blueprint
Overview

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 and continue reading to get started.

Requirements

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

Installation

You can install Blueprint via composer using the following command:

composer require --dev laravel-shift/blueprint

Blueprint will automatically register itself using package discovery.

Additional Configuration: If you are running Laravel 8, or registering class-based routes or using the app/Models folder, you will need to configure Blueprint. Please review the Blueprint Docs for additional guidance.

Basic Usage

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

php artisan blueprint:build [draft]

The draft file contains a definition of the components to generate.

Let's review the following, example draft file to generate 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: post.index

From these simple 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.

Note: This example assumes features within a default Laravel application such as the User model and app.blade.php layout. Otherwise, the generated test 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 8). 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.

Comments
  • softDeletes not working

    softDeletes not working

    Hello there.
    I'm new to here and following README to experience blueprint world.

    error_blueprint_softdeletes_00

    When I add softDeletes to model in yaml, it throws parse exception like below.

    error_blueprint_softdeletes

    I saw related issue #45, seems that this is fixed.
    But no good with shorthands for me. It works good with valid yaml syntax like softDeletes: true.

    Is this feature(shorthands) unavailable now?

    opened by MeowKim 21
  • Generate foreign key constraints

    Generate foreign key constraints

    This adds support for foreign key constraints. While syntax existed for defining foreign keys, it was incomplete.

    So there's quite a lot in this PR. More than I might have originally added to Blueprint. As such, future enhancements on this will be limited as I believe it would be faster for you to make any additional adjustments by hand.

    With that said, this PR includes:

    • A new use_constraints config option to always generate foreign key constraints for id and uuid columns where the column name follows Laravel conventions. This option is disabled by default.
    • if you wish to generate foreign key constraints for some fields, but not all, you may also add the foreign modifier to your column definition to generate constraints.
    • Improved granularity when using the foreign syntax to supply the foreign table or model reference, with or without a column name. For example, foreign:country, foreign:Country, foreign:countries, and foreign:countries.id are all examples of acceptable formats. However, this should only be need when you use unconventional names or foreign keys.
    • Support for Laravel 7 streamlined foreignId, constrained, and cascadeOnDelete methods.

    This supersedes #141 and closes #137

    opened by jasonmccreary 18
  • feat: publish stubs

    feat: publish stubs

    This PR allows users to publish all of Blueprint's stubs to /stubs/blueprint directory for customization.

    Usage: php artisan vendor:publish --tag blueprint-stubs

    It currently does not use Laravel 7's stubs. #164

    opened by ghostwriter 17
  • Resource: api.store is being added to web.php instead of api.php

    Resource: api.store is being added to web.php instead of api.php

    • Laravel Version: 7.12.0
    • PHP Version: 7.4.3
    • Blueprint Version: 1.12
    • Platform: Windows

    Description:

    Resources are not added as api routes when using resource: api.store, api.destroy.

    Steps To Reproduce:

    Run blueprint:build

    draft.yaml:

    controllers:
      UserController:
          resource: api.store, api.show, api.update
    
    bug 
    opened by dishereandy 16
  • Feature: invokable controllers

    Feature: invokable controllers

    This change allows to properly generate routes for invokable controllers, by defining an __invoke method on a controller.

    Considering a definition like the following:

    controllers:
      Report:
        __invoke:
          render: report
    

    Before the change, the generated route would be Route::get('/report', [App\HttpControllers\ReportController::class, '__invoke']); (or Route::get('/user/{id}', 'ReportController@__invoke']); without tuples).

    After the change, the generated route is Route::get('/report', App\HttpControllers\ReportController::class); (or Route::get('/report', 'ReportController'); without tuples).

    opened by jakub-wolowski 14
  • Default to plural api route naming, with config to allow plural or singular

    Default to plural api route naming, with config to allow plural or singular

    Fixes #480

    Issue created requiring plural api resource slugs. Hopefully this covers the issue as you requested @pktharindu?

    This implementation seems very simple, so there may be more needed, so happy to take any pointers @jasonmccreary or @pktharindu

    opened by benjam-es 13
  • Worked on #137 (Foreign key constraints for pivot tables)

    Worked on #137 (Foreign key constraints for pivot tables)

    This PR addresses #137 Note, forgot to update the default foreign keys for the belongsTo relation, will fix tomorrow!

    I created foreign key constraints for the pivot tables. I also wrote tests but they failed to execute, didn't have time today to figure out why. There is also an issue where I test whether the Laravel version is 7.0.0 or higher but I failed to execute the test in the testcase since it validates whether App::version() is greater or equal to 7.0.0 and I couldn't find a clean way to change this in the test.

    I hope you can take a look at this, I made it in a couple of hour and will attempt to look at it again tomorrow, If you think this is sufficient or you can fix the trailing issues yourself you're welcome.

    opened by mikevandiepen 13
  • Added path option to Trace command

    Added path option to Trace command

    Hi @jasonmccreary.

    Until now Trace Command would read files from app path, or if set, it would read files from config('blueprint.models_namespace').

    This PR adds the possibility to trace models outside app, for instance, developers may load files from .\vendor\... or .\packages\..., and they may provide multiple paths, comma separated.

    php artisan blueprint:trace --path="vendor\spatie\laravel-permission\src\Models,packages\my-package\src\Models"
    Traced 7 models
    

    The appClasses function now loads the file content to get its namespace, previously it was using the path of the working folder (for instance, app or app\Models) and the filename, to infer App\Models\User.

    Since now we can load files from other paths, like vendor\spatie\laravel-permission\src\Models we can't infer the namespace from that path, hence the file content is loaded to get the correct namespace Spatie\Permission\Models\Role.

    I've also fixed the tests in order to receive the extra path argument, and added a Test to check if the option is received.

    I tried to make the PR as short as possible, changing only the necessary lines. Let me know if I miss something with this approach.

    opened by promatik 12
  • Tests: ResourceControllerTest store_saves() fails due faulty test method

    Tests: ResourceControllerTest store_saves() fails due faulty test method

    • Laravel Version: 7.11.0
    • PHP Version: 7.4.4
    • Blueprint Version: 1.11.0
    • Platform: Mac

    Description:

    Tests generated for a resource: api controller do not use a factory.

        public function store_saves()
        {
            $certificate = $this->faker->word; // shouldn't this whip up a new certificate?
    
            $response = $this->post(route('certificate.store'), [
                'certificate' => $certificate,
            ]);
    
            $certificates = Certificate::query()
                ->where('certificate', $certificate) // shouldn't this lookup $certificate->id (or ::find() it?
                ->get();
            $this->assertCount(1, $certificates);
            $certificate = $certificates->first(); // not sure why this is here?
        }
    

    Also, looking at the other tests, I think that the Test Generator can do with a bit of tender love and care: A lot of tests do not assert anything.

    Steps To Reproduce:

    1. Add the following contents to draft.yaml:
    models:
      Certificate:
        name: string
        certificate_type_id: id
        reference: string
        document: string
        expiry_date: date
        remarks: nullable text
      CertificateType:
        name: string
        relationships:
          hasMany: Certificate
    
    controllers:
      Certificate:
        resource: api
      CertificateType:
        resource: api
    
    1. Issue a php artisan blueprint:build, which will yield:
    ❯ a blueprint:build                                                                                                                                                     48%
    Created:
    - database/migrations/2020_05_15_072744_create_certificates_table.php
    - database/migrations/2020_05_15_072745_create_certificate_types_table.php
    - app/Certificate.php
    - app/CertificateType.php
    - database/factories/CertificateFactory.php
    - database/factories/CertificateTypeFactory.php
    - app/Http/Controllers/CertificateController.php
    - app/Http/Controllers/CertificateTypeController.php
    - app/Http/Requests/CertificateStoreRequest.php
    - app/Http/Requests/CertificateUpdateRequest.php
    - app/Http/Requests/CertificateTypeStoreRequest.php
    - app/Http/Requests/CertificateTypeUpdateRequest.php
    - app/Http/Resources/CertificateCollection.php
    - app/Http/Resources/Certificate.php
    - app/Http/Resources/CertificateTypeCollection.php
    - app/Http/Resources/CertificateType.php
    - tests/Feature/Http/Controllers/CertificateControllerTest.php
    - tests/Feature/Http/Controllers/CertificateTypeControllerTest.php
    
    Updated:
    - routes/web.php
    
    1. Run phpunit, which yields:
    ❯ phpunit                                                                                                                                                               48%
    PHPUnit 8.5.4 by Sebastian Bergmann and contributors.
    
    ..R.FR.R.R.FR.R.                                                  16 / 16 (100%)
    
    Time: 457 ms, Memory: 30.00 MB
    
    There were 2 failures:
    
    1) Tests\Feature\Http\Controllers\CertificateControllerTest::store_saves
    Failed asserting that actual size 0 matches expected size 1.
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateControllerTest.php:55
    
    2) Tests\Feature\Http\Controllers\CertificateTypeControllerTest::store_saves
    Failed asserting that actual size 0 matches expected size 1.
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateTypeControllerTest.php:55
    
    --
    
    There were 6 risky tests:
    
    1) Tests\Feature\Http\Controllers\CertificateControllerTest::index_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateControllerTest.php:21
    
    2) Tests\Feature\Http\Controllers\CertificateControllerTest::show_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateControllerTest.php:63
    
    3) Tests\Feature\Http\Controllers\CertificateControllerTest::update_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateControllerTest.php:86
    
    4) Tests\Feature\Http\Controllers\CertificateTypeControllerTest::index_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateTypeControllerTest.php:21
    
    5) Tests\Feature\Http\Controllers\CertificateTypeControllerTest::show_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateTypeControllerTest.php:63
    
    6) Tests\Feature\Http\Controllers\CertificateTypeControllerTest::update_behaves_as_expected
    This test did not perform any assertions
    
    /Users/joostjacobs/Code/blueprint/tests/Feature/Http/Controllers/CertificateTypeControllerTest.php:86
    
    FAILURES!
    Tests: 16, Assertions: 20, Failures: 2, Risky: 6.
    
    1. Inspect the CertificateControllerTest, particularly the store_saves test:
        /**
         * @test
         */
        public function store_saves()
        {
            $certificate = $this->faker->word;
    
            $response = $this->post(route('certificate.store'), [
                'certificate' => $certificate,
            ]);
    
            $certificates = Certificate::query()
                ->where('certificate', $certificate)
                ->get();
            $this->assertCount(1, $certificates);
            $certificate = $certificates->first();
        }
    
    bug in progress 
    opened by axit-joost 12
  • Idea: config/blueprint.php in which you can define output paths

    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.

    opened by axit-joost 12
  • Errors running blueprint on fresh Laravel + Sail + Jetstream setup

    Errors running blueprint on fresh Laravel + Sail + Jetstream setup

    • Laravel Version: 8.22.1
    • PHP Version: 8.0.0
    • Blueprint Version: 1.20.1
    • Platform: Linux (WSL2)
    • Sail: 1.1.0
    • Jetstream: 2.1.0

    Issue:

    When running

    sail artisan blueprint:build
    

    I get the following error:

    [2021-01-13 13:33:15] local.ERROR: Call to a member function columns() on null {"exception":"[object] (Error(code: 0): Call to a member function columns() on null at /var/www/html/vendor/laravel-shift/blueprint/src/Generators/TestGenerator.php:251) [stacktrace] #0 /var/www/html/vendor/laravel-shift/blueprint/src/Generators/TestGenerator.php(89): Blueprint\\Generators\\TestGenerator->buildTestCases() #1 /var/www/html/vendor/laravel-shift/blueprint/src/Generators/TestGenerator.php(64): Blueprint\\Generators\\TestGenerator->populateStub() #2 /var/www/html/vendor/laravel-shift/blueprint/src/Blueprint.php(85): Blueprint\\Generators\\TestGenerator->output() #3 /var/www/html/vendor/laravel-shift/blueprint/src/Builder.php(26): Blueprint\\Blueprint->generate() #4 /var/www/html/vendor/laravel-shift/blueprint/src/Commands/BuildCommand.php(65): Blueprint\\Builder->execute() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Blueprint\\Commands\\BuildCommand->handle() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(610): Illuminate\\Container\\BoundMethod::call() #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call() #11 /var/www/html/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute() #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #13 /var/www/html/vendor/symfony/console/Application.php(971): Illuminate\\Console\\Command->run() #14 /var/www/html/vendor/symfony/console/Application.php(290): Symfony\\Component\\Console\\Application->doRunCommand() #15 /var/www/html/vendor/symfony/console/Application.php(166): Symfony\\Component\\Console\\Application->doRun() #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run() #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run() #18 /var/www/html/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #19 {main} "}

    It builds the controllers and models, but not the views/tests.

    When then trying to run the erase

    sail artisan blueprint:erase
    

    I get the following error:

    [2021-01-13 13:33:34] local.ERROR: File does not exist at path .blueprint. {"exception":"[object] (Illuminate\\Contracts\\Filesystem\\FileNotFoundException(code: 0): File does not exist at path .blueprint. at /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:57) [stacktrace] #0 /var/www/html/vendor/laravel-shift/blueprint/src/Commands/EraseCommand.php(47): Illuminate\\Filesystem\\Filesystem->get() #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Blueprint\\Commands\\EraseCommand->handle() #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(610): Illuminate\\Container\\BoundMethod::call() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call() #7 /var/www/html/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute() #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #9 /var/www/html/vendor/symfony/console/Application.php(971): Illuminate\\Console\\Command->run() #10 /var/www/html/vendor/symfony/console/Application.php(290): Symfony\\Component\\Console\\Application->doRunCommand() #11 /var/www/html/vendor/symfony/console/Application.php(166): Symfony\\Component\\Console\\Application->doRun() #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run() #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run() #14 /var/www/html/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #15 {main} "}

    I've tried it on another fresh Laravel/Sail/Jetstream install as well with same result.

    draft.yaml:

    models:
      Category:
        category_id: id 
        category: string
        timestamps: false
      
      Role:
        role_id: id
        role: string
        timestamps: false
      
      Person:
        person_id: id
        profile_image_path: string nullable
        name: string
        is_female: boolean
        is_actor: boolean
        is_dead: boolean
        birthdate: datetime nullable
        deathdate: datetime nullable
        burial_place: string nullable
        nationality: string nullable
        city: string nullable
        country: string nullable
        education: string nullable
        short_intro: longtext nullable
        biography: longtext nullable
        birth_city: string nullable
        birth_country: string nullable
        timestamps: false
      
      Relation:
        relation_id: id
        person_id: id
        relation: string
        related_person_id: id foreign:person
        timestamps: false
      
      Starsign:
        starsign_id: id
        name: string
        description: longtext nullable
        from_date: datetime
        to_date: datetime
        timestamps: false
      
      Movie:
        movie_id: id
        title: string
        publishing_date: datetime nullable
        cover: string nullable
        category_id: id
        timestamp: false
      
      Characters:
        character_id: id
        name: string
        timestamp: false
      
      MovieCharacter:
        movie_character_id: id
        character_id: id
        movie_id: id
        role_part: string nullable
        picture: string nullable
        timestamp: false
      
      MovieProduction:
        movie_production_id: id
        person_id: id
        role_id: id
        movie_character_id: id
        timestamp: false
      
      TvSeries:
        tv_series_id: id
        title: string
        publishing_date: datetime nullable
        cover: string nullable
        category_id: id
        seasons: integer nullable
        timestamp: false
    
      TvSeriesEpisode:
        tv_series_episode_id: id
        tv_series_id: id
        episode_number: integer nullable
        title: string
        publishing_date: datetime nullable
        cover: string nullable
        season: integer nullable
        timestamp: false
    
    
      TvSeriesCharacters:
        tv_series_characters_id: id
        character_id: id
        tv_series_id: id
        picture: string nullable
        role_part: string nullable
        timestamp: false
    
      TvSeriesProduction:
        tv_series_production_id: id
        tv_series_episode_id: id
        person_id: id
        role_id: id
        tv_series_character_id: id
        timestamp: false
    
    controllers:
      Movie:
        resource
    
      TvSeries:
        resource
      
      Episode:
        resource
      
      Character:
        resource
      
      Category:
        resource
    
      Role:
        resource
    
      Person:
        resource
    
      Relation:
        resource
      
    

    Am I doing something wrong?

    bug pending 
    opened by KimLangholz 11
  • Need ignore softDeletesTz and softDeletes in resources and requests

    Need ignore softDeletesTz and softDeletes in resources and requests

    • Laravel Version: 9.14
    • PHP Version: 8.1
    • Blueprint Version: 2.4
    • Platform: Windows

    Issue:

    In app/Http/Resources/PostResource.php:

            return [
                'id' => $this->id,
                'title' => $this->title,
                'softdeletestz' => $this->softdeletestz,
            ];
    

    In app/Http/Requests/PostStoreRequest.php:

            return [
                'title' => ['required'],
                'softdeletestz' => ['required'],
            ];
    

    draft.yaml:

    Post:
        title: string:400
        softDeletesTz
    
    bug 
    opened by FlashWS 1
  • Specifying size of integer columns

    Specifying size of integer columns

    • Laravel Version: 9.29.0
    • PHP Version: 8.10.0
    • Blueprint Version: 2.4.0
    • Platform: Mac | Windows | Linux

    Issue:

    When using size attribute with any integer blueprint integer (bigInteger, mediumInteger, tinyInteger, smallInteger, etc...), it will generate a Laravel migration format that call SQL to create a Primary Key with Auto Increment. Please check this similar generated Issue.

    draft.yaml:

    code_no: smallInteger:3 unsigned unique
    

    will generate

    $table->unsignedSmallInteger('code_no', 3)->unique()
    

    It maybe more adequate to generate

    $table->unsignedSmallInteger('code_no')->length(3)->unique()
    
    bug 
    opened by mahfoudfx 4
  • Add Foreign key column to Relationship in Model

    Add Foreign key column to Relationship in Model

    Synopsis:

    While creating a model columns with custom column name (doesn't follow laravel convention). It doesn't add column name to relation.

    So let's say i have following Yaml

    Sample 1

    models:
      Post:
        id
        content: text nullable
        created_by_id: id nullable bigInteger unsigned foreign:users.id
        timestamps
        softDeletes
    

    Expected Behavior:

    While generating Model relations It can automatically add created_by_id as second argument. And

    public function createdBy(): \Illuminate\Database\Eloquent\Relations\BelongsTo
        {
            return $this->belongsTo(\App\Models\User::class,"created_by_id");
        }
    

    Sample 2

    models:
      Post:
        id
        content: text nullable
        created_by_id: id nullable bigInteger unsigned foreign:users.user_id
        timestamps
        softDeletes
    

    Expected Behavior:

    While generating Model relations It can automatically add created_by_id and as second argument as user_id

    public function createdBy(): \Illuminate\Database\Eloquent\Relations\BelongsTo
        {
            return $this->belongsTo(\App\Models\User::class,"created_by_id","user_id");
        }
    
    enhancement 
    opened by ManojKiranA 1
  • Nested Resources

    Nested Resources

    Synopsis:

    The ability to generate nested resources for other models/controllers. For example:

    A job can have many comments, but a course could also have many comments, and they would use a Comment model, with a commentable morph (which we can do already), now to comment on a job with Laravel you can do:

    web.php

    Route::resource('job.comment', JobCommentController::class);
    

    JobCommentController.php

    class JobCommentController extends Controller
    {
        /**
         * Store a newly created resource in storage.
         *
         * @param \Illuminate\Http\Request $request
         * @param \App\Models\Job $job
         * @param \App\Models\Comment $comment
         * @return \Illuminate\Http\Response
         */
        public function store(CommentRequest $request, Job $job, Comment $comment)
        {
            $comment = $job->comments()->create(array_merge([
                'owner_type' => 'user',
                'owner_id' => Auth::user()->id
            ], $request->validated()));
    
            return Redirect::back()->withSuccess('You have added a comment to this job');
        }
    }
    

    Currently we don't have a way to do this. Would this be something you're open to?

    Proposed Syntax:

        # Job Comment Controller
        Job/JobComment:
            resource: store, destroy
            model: job
            nested: comment
            validation: comment/comment
    

    So, the model is the resource model It is nested for, and nested is the model it uses to store/delete data, the validation is the file It generates for validation. Because the comment is used for multiple resources, it doesn't make sense to add that under the Requests/Job/ folder but the nested model's own folder, so you could use CommentStoreValidation for both Jobs and courses or whatever other model can be commented on.

    enhancement 
    opened by natecorkish 0
  • Friendly warning for missing models

    Friendly warning for missing models

    Synopsis:

    It's possible if a user runs blueprint:build for an existing app (or a draft.yaml file with references the User model) it's likely they may receive a nasty error.

    This is often mitigated by running blueprint:trace. Yet there is no indication to do so. In the end, this is a poor out-of-the-box experience.

    Expected Behavior:

    Given the following draft.yaml file, it would be better if an error message were thrown letting the user know they have an "unknown model" and to either define it or run blueprint:trace if it exists already.

    controllers:
      User:
        resource: api
    

    A centralized place to throw this error might be modelForContext. However, sometimes Blueprint handles a missing models. So these will likely need to be reviewed, but maybe a second throw parameter could be added.

    enhancement 
    opened by jasonmccreary 1
  • Ability to publish and customize stubs, possibly align with Laravel stubs

    Ability to publish and customize stubs, possibly align with Laravel stubs

    Hey there,

    I was wondering if it was possible we could get different stubs for the views other than blade. For example; Inertia.js, Livewire, Vue components perhaps?, other frameworks I probably don’t know about.

    If this isn’t really feasible because you don’t want to maintain things like that, is it possible we could get some sort of way to define a custom stub? Perhaps provide a path where the files should be created in a config as well as the path to the stub we want to use?

    Fairly new to this package but I’m a big fan and I feel like this is one of the features that will allow more developers of different frameworks to reap the benefits of this amazing package! (Especially since a lot of projects call for something other than blade SSR)

    enhancement 
    opened by marbuser 15
Releases(v2.4.0)
  • v2.4.0(May 23, 2022)

    Added

    • Support fullText column data type (#551)

    Fixed

    • Fix for variables without context (#553)
    • Replace assertDeleted with assertModelMissing (#554)
    • Exclude softDeletes columns from factory definition (#565)
    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Feb 12, 2022)

  • v2.2.0(Feb 9, 2022)

    Added

    • Add options to publish stubs + config (#530)
    • Show skipped views in the output of build command (#531)

    Fixed

    • Respect order for soft deletes columns (#534)
    • Allow multiple morphTo statements (#535)

    Refactors

    • Refactor to abstract class and specific traits (#532)
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Dec 29, 2021)

    Added

    • Use foreignUuid method to replace uuid and foreign chain (#502)
    • Do not use FQCN for model relationships in same namespace (#524)
    • Support Many to Many Polymorphic (#522)
    • Use modern App/Models namespace as default (#521)

    Fixed

    • Update README to reflect new supported versions (#499)
    • Change property to protected for extension (#500)
    • Fix Trace command to ignore non-PHP files (#498)
    • Remove Laravel 7 or newer checks. (#504)
    • Fix migration for FQCN references (#503)
    • Fix model namespace in the generated factory class. (#512)
    • Remove double line break before first relationship method (#517)
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Aug 17, 2021)

    This is a superficial major version release. It marks the adoption of a new Support Policy by dropping support for old version of Laravel (currently 6.x, 7.x). There are no major changes to Blueprint's functionality or underlying code. You may review the Upgrade Guide for full details.

    Source code(tar.gz)
    Source code(zip)
  • v1.25.0(Aug 13, 2021)

    Added

    • Add --path option to blueprint:trace external models (#488)
    • Output related models when available in resources (#495)
    • Add support for useCurrentOnUpdate modifier (#493)

    Fixed

    • Set return types in DocBlock when using resources (#494)
    • Make relativeClassName return class name relative to models namespace (#491)
    Source code(tar.gz)
    Source code(zip)
  • v1.24.2(Aug 6, 2021)

    Fixed

    • Refactor filesystem mocks (#449)
    • Determine correct model for context (#477)
    • Allow non-id columns to be nullable when using foreign (#486)
    Source code(tar.gz)
    Source code(zip)
  • v1.24.1(Apr 28, 2021)

  • v1.24.0(Apr 22, 2021)

  • v1.23.3(Apr 15, 2021)

  • v1.23.2(Apr 3, 2021)

  • v1.23.1(Mar 27, 2021)

  • v1.23.0(Mar 19, 2021)

    Added

    • blueprint:init console command (#438)
    • String limit for faker words (#437)
    • Shorthand for invokable controllers (#435)

    Fixed

    • Output of numeric defaults (#445)
    • Generate correct reference for nested models (#447)
    • Typo (#446)
    Source code(tar.gz)
    Source code(zip)
  • v1.22.0(Feb 23, 2021)

    Added

    • Add additional PHPDoc annotation (#427)
    • Support onUpdate clauses for migrations (#425)

    Fixed

    • Fix boolean column default modifier (#426) …
    • Fix duplicate and missing return type declarations (#433)
    Source code(tar.gz)
    Source code(zip)
  • v1.21.0(Jan 25, 2021)

    Added

    • Generate belongsTo relationship for UUID columns
    • Generate return type declarations (#404)

    Fixed

    • Do not generate foreign key for simple UUID column (#418)
    Source code(tar.gz)
    Source code(zip)
  • v1.20.2(Jan 16, 2021)

  • v1.20.1(Jan 5, 2021)

  • v1.20.0(Dec 5, 2020)

    Changed

    • Use $casts instead of $dates property from models on L8+ (#393)

    Fixed

    • Correct newline character for windows (#394)
    • Invalid UUID relationships (#398)
    Source code(tar.gz)
    Source code(zip)
  • v1.19.2(Oct 23, 2020)

    Added

    • Run tests when pushing to master branch (#372)
    • Build demo app via Github Actions (#371)
    • Note required configuration for Laravel 8 (11f475c)

    Fixed

    • The destroy test should assert for SoftDeleted (#381)
    • Set a date format on a date column for update test. (#380)
    • Pivot table naming when model name contains path prefix (#388)
    Source code(tar.gz)
    Source code(zip)
  • v1.19.1(Sep 27, 2020)

  • v1.19.0(Sep 27, 2020)

    Added

    • Laravel 8 class-based model factories (#365)
    • Generate tests using Laravel 8 model factories (#367)

    Fixed

    • View generator test and fixtures (#373)
    • Fix multi-word models + refactors (#376)

    Refactored

    • Update build action (#363)
    • Remove all duplicates when overwriting migrations (#375)
    • Cleanup fixtures (#368)
    Source code(tar.gz)
    Source code(zip)
  • v1.18.0(Sep 7, 2020)

    Added

    • Alias method names for relationships (#355)
    • Allow swapping custom generators via config (#357)
    • Toggle foreign key constraints for Migrations (#356)
    • Bump dependencies for Laravel 8 (#364)

    Fixed

    • Fix PSR-4 autoload naming for Generators (#362)

    Refactored

    • Add .editorconfig file (#359)
    • Refactor: streamline tests (#361)
    • Leverage config merging to default generators (https://github.com/laravel-shift/blueprint/commit/ef82b5b463dddc18a3ea11277b942dba8053f5b8)
    Source code(tar.gz)
    Source code(zip)
  • v1.17.0(Aug 28, 2020)

    Added

    • Add support for route generation using FQCN (#323)
    • Add support for namespaced JsonResources (#330)
    • Generate FormRequest rules using array syntax (#345)
    • Add -m shortcut for --overwrite-migrations option (#346)
    • Generate migration columns with comments (#347)
    • Add support for generating indexes (#351)

    Fixed

    • Change api.delete to return proper "no content" (#331)
    • Cast date columns (#341)
    • Support namespaced Resources + suffix name (#342)

    Refactored

    • Update trace command to increase the reusability and testability (#318)
    • Stubs helper (#333)
    Source code(tar.gz)
    Source code(zip)
  • v1.16.0(Aug 13, 2020)

    Added

    • --overwrite-migrations option for blueprint:build (#319)
    • Publishing of Blueprint stubs for customization (#312)

    Refactored

    • Backfill tests for commands (#315, #320)
    Source code(tar.gz)
    Source code(zip)
  • v1.15.3(Jul 23, 2020)

    Fixed

    • Use $request->validated for save with validate statement (#308)

    Refactored

    • Make generator classes extendable (#297)
    • Refactor shouldGenerate using collection (#299)
    • Test class to match the command class name (#302)
    • Extract common logic to abstract generator (#303)
    • Introduce Tree class to manage the analyzed tokens (#304)
    • Use shared faker-registry package (#309)
    Source code(tar.gz)
    Source code(zip)
  • v1.15.2(Jul 16, 2020)

    Fixed

    • Use assertCreated for new Resource responses (https://github.com/laravel-shift/blueprint/commit/d5641d32dc6ae6410a0547f4968e2a0dd57e81dd)
    • Update with request data when using validation (#295)
    Source code(tar.gz)
    Source code(zip)
  • v1.15.1(Jul 9, 2020)

    Fixed

    • Use strict check on null instead of empty() for modifiers with 0 values (#286)
    • Generate assertions for Eloquent update statements (#288)
    • Generate simple assertions for resource statements (#290)
    Source code(tar.gz)
    Source code(zip)
  • v1.15.0(Jul 8, 2020)

    Added

    • --only and --skip options for blueprint:build (#276)

    Fixed

    • Generate proper test setup for validate shorthand (#280)
    • Use factory for referenced models in validate statements (#282)
    Source code(tar.gz)
    Source code(zip)
  • v1.14.0(Jun 26, 2020)

  • v1.13.2(Jun 19, 2020)

Owner
Laravel Shift
Laravel Shift is an automated service for upgrading your Laravel applications.
Laravel Shift
A simple package that helps PHP developers to generate the QR code signature as per Zakat authority (ZATCA) requirements of Saudi Arabia.

A PHP package that implements the e-invoice QR code signature requirements as designed by the Zakat authority of Saudi Arabia. How to install? compose

Muktar Sayed Saleh 5 Jun 13, 2022
Rapid form generation with Bootstrap 3 and Laravel.

Important: This package is not actively maintained. For bug fixes and new features, please fork. BootForms BootForms builds on top of my more general

Adam Wathan 423 Jun 14, 2022
Manage your staff from one place. Featuring Staff leave management 🏖, payslips 💵 generation & emailing, messaging 📨and more 🛠! Built with ❤️ with Laravel

Staff Management System This little buddy can help you manage your staff database! Built with ?? with Laravel #FEATURES 1 Staff management/ database S

Ezekiel Oladejo 45 Jan 3, 2023
Localization Helper - Package for convenient work with Laravel's localization features and fast language files generation

Localization Helper Package for convenient work with Laravel's localization features and fast language files generation. Installation Via Composer $ c

Galymzhan Begimov 0 Jul 13, 2019
Painless html generation

Painless html generation This package helps you generate HTML using a clean, simple and easy to read API. All elements can be dynamically generated an

Spatie 616 Dec 28, 2022
Framework - 🙃 Phony. Real-like Fake Data Generation Framework

?? Framework This repository contains the ?? Phony Framework. ?? Start generating fake data with ?? Phony Framework, visit the main Phony Repository.

Phonyland 5 Oct 31, 2022
A nice GUI for Laravel Artisan, ready out of the box, configurable and handy for non-CLI experienced developers.

Artisan UI A nice GUI for Laravel Artisan, ready out of the box, configurable and handy for non-CLI experienced developers. Supported commands must be

Pablo Leone 1 Dec 3, 2021
Fully customizable and tests supported Laravel admin dashboard for developers.

Laravel Admin dashboard Like Laravel Jetstream but built with Hotwire Turbo + additional perks. Tools used: tailwindcomponents/dashboard Hotwire Turbo

null 12 Nov 1, 2022
A Laravel package to scrub sensitive information that breaks operational security policies from being leaked on accident or not by developers.

A Laravel package to scrub sensitive information that breaks operational security policies from being leaked on accident or not by developers.

YorCreative 104 Jan 6, 2023
Remita Clone for PHP-CURL Developers

REMITA - Empower your Customers to pay you easily as you grow Description Remita clone app (PHP) was build to ease programmers to integerate remita pa

Abdurrahim Yahya Muazu 4 Mar 31, 2022
A tool to automatically fix PHP Coding Standards issues by Dragon Code.

The Dragon Code Styler Installation Required PHP: ^8.0 Composer: ^2.0 Locally composer global require dragon-code/codestyler Usage When you run the co

The Dragon Code 24 Aug 27, 2022
🔌 Convert Bootstrap CSS code to Tailwind CSS code

Tailwindo This tool can convert Your CSS framework (currently Bootstrap) classes in HTML/PHP (any of your choice) files to equivalent Tailwind CSS cla

Awssat 938 Dec 24, 2022
Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS.

Nebula Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS. Nebula m

Nebula 228 Nov 11, 2022
Thunder is an advanced Laravel tool to track user consumption using Cashier's Metered Billing for Stripe. ⚡

⚡ Thunder Thunder is an advanced Laravel tool to track user consumption using Cashier's Metered Billing for Stripe. ⚡ ?? Supporting If you are using o

Renoki Co. 10 Nov 21, 2022
Laracademy Generators - is a tool set that helps speed up the development process of a Laravel application.

Laracademy Generators Laracademy Generators - is a tool set that helps speed up the development process of a Laravel application. Author(s): Laracadem

Laracademy 320 Dec 24, 2022
An issue tracking tool based on laravel+reactjs for small and medium-sized enterprises, open-source and free, similar to Jira.

ActionView English | 中文 An issue tracking tool based on php laravel-framework in back-end and reactjs+redux in front-end, it's similar to Jira. You co

null 1.7k Dec 23, 2022
This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.

Laravel Nova tool for running Artisan & Shell commands. This Nova tool lets you run artisan and bash commands directly from nova. This is an extended

Artem Stepanenko 17 Dec 15, 2022
A minimalistic event calendar Tool for Laravel's Nova 4

Event calendar for Laravel Nova 4 An event calendar that displays Nova resources or other time-related data in your Nova 4 project on a monthly calend

wdelfuego 44 Jan 1, 2023
This Laravel Nova settings tool based on env, using nativ nova fields and resources

Nova Settings Description This Laravel Nova settings tool based on env, using nativ nova fields and resources Features Using native Nova resources Ful

Artem Stepanenko 21 Dec 28, 2022