From 9df4823bf649226575d1d65dceb0895be3b6f2f1 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Thu, 16 Apr 2020 22:34:49 +0200 Subject: [PATCH] WIP@ --- README.md | 34 +++++++++++++++++------ composer.json | 11 ++------ src/BlueprintNovaAddonServiceProvider.php | 9 +++--- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 41941bf..bbf654a 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,44 @@ -# Very short description of the package +# Blueprint Nova Addon [![Latest Version on Packagist](https://img.shields.io/packagist/v/naoray/blueprint-nova-addon.svg?style=flat-square)](https://packagist.org/packages/naoray/blueprint-nova-addon) [![Build Status](https://img.shields.io/travis/naoray/blueprint-nova-addon/master.svg?style=flat-square)](https://travis-ci.org/naoray/blueprint-nova-addon) -[![Quality Score](https://img.shields.io/scrutinizer/g/naoray/blueprint-nova-addon.svg?style=flat-square)](https://scrutinizer-ci.com/g/naoray/blueprint-nova-addon) [![Total Downloads](https://img.shields.io/packagist/dt/naoray/blueprint-nova-addon.svg?style=flat-square)](https://packagist.org/packages/naoray/blueprint-nova-addon) -This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. +:mega: Shoutout to [Jason McCreary](https://github.com/jasonmccreary) whose [Blueprint](https://github.com/laravel-shift/blueprint) package lays the groundwork for this small addon. Thank you Jason :raised_hands: -## Installation +Installing this addon will allow you to generate your Nova resources with the `php artisan blueprint:build` command. +## Installation You can install the package via composer: ```bash -composer require naoray/blueprint-nova-addon +composer require naoray/blueprint-nova-addon --dev ``` -## Usage +> :warning: You need to have [laravel nova](nova.laravel.com/) installed in order for the resource generation to take place! -``` php -// Usage description here +## Usage +Refer to [Blueprint's Basic Usage](https://github.com/laravel-shift/blueprint#basic-usage) to get started. Afterwards you can run the `blueprint:build` command to generate Nova resources automatically. To get an idea of how easy it is you can use the example `draft.yaml` file below. + +```yaml +# draft.yaml +models: + Post: + author_id: id:user + title: string:400 + content: longtext + published_at: nullable timestamp + relationships: + HasMany: Comment + + Comment: + post_id:i + content: longtext + published_at: nullable timestamp ``` +From these simple 20 lines of YAML, Blueprint will generate all of the following Laravel components: + ### Testing ``` bash diff --git a/composer.json b/composer.json index 3c2bca4..c99409f 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "require": { "illuminate/pipeline": "^7.0", "illuminate/support": "^7.0", - "laravel-shift/blueprint": "^1.5", - "laravel/nova": "^3.4" + "laravel-shift/blueprint": "^1.5" }, "require-dev": { "orchestra/testbench": "^5.0", @@ -48,11 +47,5 @@ "Naoray\\BlueprintNovaAddon\\BlueprintNovaAddonServiceProvider" ] } - }, - "repositories": [ - { - "type": "composer", - "url": "https://nova.laravel.com" - } - ] + } } diff --git a/src/BlueprintNovaAddonServiceProvider.php b/src/BlueprintNovaAddonServiceProvider.php index ab3147a..22f2594 100644 --- a/src/BlueprintNovaAddonServiceProvider.php +++ b/src/BlueprintNovaAddonServiceProvider.php @@ -2,6 +2,7 @@ namespace Naoray\BlueprintNovaAddon; +use Blueprint\Blueprint; use Illuminate\Support\ServiceProvider; class BlueprintNovaAddonServiceProvider extends ServiceProvider @@ -11,10 +12,10 @@ class BlueprintNovaAddonServiceProvider extends ServiceProvider */ public function register() { - // $this->app->extends(Blueprint::class, function ($app) { - // $blueprint->registerGenerator(new \Blueprint\Generators\TestGenerator($app['files'])); + $this->app->extend(Blueprint::class, function ($blueprint, $app) { + $blueprint->registerGenerator(new NovaGenerator($app['files'])); - // return $blueprint; - // }); + return $blueprint; + }); } }