Giter Site home page Giter Site logo

mtolhuys / laravel-schematics Goto Github PK

View Code? Open in Web Editor NEW
1.5K 32.0 133.0 9.44 MB

A Laravel package making a diagram of your models, relations and the ability to build them with it

License: MIT License

PHP 41.58% JavaScript 14.33% Vue 42.98% SCSS 0.04% Blade 1.07%
diagrams explanation drag drop schematics laravel

laravel-schematics's Introduction

Laravel Schematics

Latest Version on Packagist Build Status Quality Score Total Downloads

This package allows you to make multiple diagrams of your Eloquent models and their relations. It will help building them providing drag and drop relations, forms to create and edit your models and many options like adding resource controllers, form requests and running migrations by the click of a button or (configurable) automatically. It also will give you insights in the migrations you ran and the ones specified in your migrations folder.

Schematics Example

Its aim is to help you (and your team) get more grip on the models from a code perspective, the status of your migrations and build / edit them faster.


Installation

You can install the package via composer:

composer require mtolhuys/laravel-schematics --dev

Run php artisan schematics:install which will do the route caching, create vendor assets in your public folder and setup the configuration file.

Or...

php artisan vendor:publish --provider="Mtolhuys\LaravelSchematics\LaravelSchematicsServiceProvider"

and visit {your-app}/schematics


Usage

Starting out / Searching

If you already have a lot of models I recommend you use the search bar to narrow down the diagrams into specific sections f.e:

Schematics Example

These searches are saved across your diagrams.

Relations

When you drag and drop the arrow to another model you'll get a form to specify the relation you want to build f.e:

Clicking on them will show something like:

Relation Example

Building / Editing Models

To specify the types of your columns I've chosen the form request rule syntax. To see what's available you can click the little help icon below the fields in the model form:

Fields Explanation

The package is flexible enough to differentiate between renaming and changing column types. It will create migrations according the need to change or create a table and setup your $fillables. I do strongly suggest you check the migrations before running them if the stakes are high.

You don't have to worry about existing migrations though, the package will only look for migrations it created itself by checking the value of the @tag in the comment it adds. It looks like this:

/**
 * Laravel Schematics
 *
 * WARNING: removing @tag value will disable automated removal
 *
 * @package Laravel-schematics
 * @author  Maarten Tolhuijs <[email protected]>
 * @url     https://github.com/mtolhuys/laravel-schematics
 * @tag     laravel-schematics-foobar-model
 */

Changing Diagram Style

There are 4 diagram styles. Bezier, Straight, Flowchart and State Machine:

Importing / Exporting Diagrams

To save and / or share the diagrams you created you can use the export and import settings feature:


Testing

You can run the tests with:

composer test

Or, optionally, with coverage information:

composer test-coverage

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

This package is possible because of the effort and time of these people! ✨


Maarten Tolhuijs

Creator️

Deisi Tolhuijs

Design

Dennis Mwea

Contributor

Robbin Schepers

Contributor

Bram van Rijswijk

Support

Lucas Snel

Contributor

Contributing

Since I'm getting some questions about this I want these things to be perfectly clear:

  • This is a safe haven for contributions, every (positive) contributon matters!
  • You are free (and encouraged) to use anything of this package for your own ideas.
  • You can always ask for help or email me directly for any questions.

Please see CONTRIBUTING for further 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.

laravel-schematics's People

Contributors

dennis-mwea avatar dependabot[bot] avatar elbojoloco avatar imanghafoori1 avatar lematosdefuk avatar micksp avatar mtolhuys avatar phpcxy avatar rpouls 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

laravel-schematics's Issues

Don't run in production env

Great package πŸ‘πŸ‘πŸ‘

Is there a way to run schematics on during development, when config('app.env') != 'production'?

about create model

An error occurred when I created the model

"message": "Use of undefined constant STDIN - assumed 'STDIN' (this will throw an Error in a future version of PHP)",
    "exception": "ErrorException",
    "file": "/Users/gabbymrh/Desktop/my_project/FunnyForum/ForumAPI/vendor/symfony/console/Helper/QuestionHelper.php",
    "line": 118,

JsonLint Parsing Exception

When I run:
composer require mtolhuys/laravel-schematics

I keep getting the following error:

[Seld\JsonLint\ParsingException] "./composer.lock" does not contain valid JSON Parse error on line 742: "time": "2020-02-25T ---------------------^ Expected one of: 'EOF', '}', ':', ',', ']'

Any ideas why?

error on schematics:install

When i run php artisan schematics:install I get this error

Screenshot from 2020-03-07 20-03-35

Let alone the localhost:8000/schematics is blank

[Feature] Improve Model add

As described on README we can add a type and a rule when creating models.

Would be nice to have two combobox with all available options for each type and rule, instead of a text field.

For flexibility in each combox a option other that will enable a input text.

Captura de tela de 2020-03-06 18 47 12

Support custom pivot models

Custom Pivot models are being included as standard models

image

(likely because they ultimately extend Model::class)

Relations that actually use these Custom model classes aren't noted as such
image

The above is an example of

    public function vessels(): BelongsToMany
    {
        return $this->belongsToMany(Vessel::class, 'users_vessels')->using(UserVesselPivot::class);
    }

I think if a class is of Pivot::class it can be ignored for layout. But as the Pivot class has its own fillable etc for use with withPivot() it could also be creatable via this package when defining relations - maybe an "Add Custom Pivot Class" option then provide the same model creation interface that already exists.

Schematics finds migrations but not models

As the subject says, schematics can find the migrations, but no models. We have written our code so that the routes are in devolved routes files - the code is separated into different modules, and each module has its own route file (eg Modules/Communication/Http/routes.php). Is there any way schematics can use this? The routes have been cached, and I can see them when I do php artisan route:list.

Thanks.

[Feature] Support namespace models and controllers

When creating a model, choose a sub namespace, For example

Namespace = Blog
Model = Post

App\Blog\Post.php
App\Http\Controllers\Blog\PostController.php
App\Http\Request\Blog\Post\CreatePostRequest.php

Namespace = Blog
Model = Comment

App\Blog\Comment.php
App\Http\Controllers\Blog\CommentController.php
App\Http\Request\Blog\Comment\CreateCommentRequest.php

Table prefix issue

The table name returned by $model->getTable() is unprefixed, causing errors on the describe query if a table prefix is present.

$safeTableName = \DB::getQueryGrammar()->wrap($table);

This could be solved by adding the prefix manually:

$safeTableName = \DB::getQueryGrammar()->wrap($model->getConnection()->getTablePrefix() . $table);

I had this issue occur on an older Laravel version: 5.7

Not tested on anything newer.

[Feature] Drag&drop relation "label" or zoom in/out

Hi

It would be nice to move relation label (see image) or zoom in/out "viewport". If we have a lot of models then it is a bit annoying when they overlap each other or when we have to scroll to find some model.

pobrane (1)

Support PostgreSQL

Really cool package, I see a huge potential here !
Let's keep it rolling :)

Model edition or features alike are not working, because commands like 'describe' do not exist on PostgreSQL

[2020-03-13 10:05:23] local.ERROR: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "describe"
LINE 1: describe "work_orders"
        ^ (SQL: describe "work_orders") {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42601): SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near \"describe\"
LINE 1: describe \"work_orders\"
        ^ (SQL: describe \"work_orders\") at /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)
[stacktrace]
#0 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Database/Connection.php(629): Illuminate\\Database\\Connection->runQueryCallback()
#1 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Database/Connection.php(338): Illuminate\\Database\\Connection->run()
#2 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(349): Illuminate\\Database\\Connection->select()
#3 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\\Database\\DatabaseManager->__call()
#4 /var/www/html/someweb/vendor/mtolhuys/laravel-schematics/src/Http/Controllers/ModelsController.php(62): Illuminate\\Support\\Facades\\Facade::__callStatic()
#5 [internal function]: Mtolhuys\\LaravelSchematics\\Http\\Controllers\\ModelsController->columns()
#6 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array()
#7 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#8 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#9 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#10 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\\Routing\\Route->run()
#11 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#12 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#13 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\\Pipeline\\Pipeline->then()
#14 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack()
#15 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\\Routing\\Router->runRoute()
#16 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute()
#17 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\\Routing\\Router->dispatch()
#18 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#19 /var/www/html/someweb/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#20 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
#21 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#22 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#23 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#24 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#25 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#26 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#27 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#28 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle()
#29 /var/www/html/someweb/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#30 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle()
#31 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then()
#33 /var/www/html/someweb/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#34 /var/www/html/someweb/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
#35 {main}

[Feature] Integrate into Pipe Dream File Factories for complete generation of all App fundamentals

With Pipe Dream you can sketch out your models and use these file factories to create Laravel App files or Laravel Nova files:

https://github.com/topics/pipe-dream-file-factory

It would be incredible if there was some way to use the power of Schematics to map out the model relationships and complete the remainder of the build using these File Factories.

Perhaps this ticket is just a jump off point for a conversation rather than a fully spec'd ticket.

Thanks!

issue with adding relationships

I created "User hasMany Posts" relationship
this is what the User.php file look like after that:

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function posts()
    {
        return $this->hasMany(\App\Models\Post::class);
    }
}

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

Problems with the relationships

Good morning!!!

I'm sorry, but my english is not good.

When I create a relationship between two models and schematics it implements it in the code of the corresponding model, it does it between the namespace declaration zone and the class, it does not add it to the end of the class, as would be correct. That must be defined somewhere or is it a bug?
user_model

And then, I have a problem with the migrations...

Please, anyone helps me?

Very beautiful project, but here I still couldn't run

Hello, how are you?
First of all I want to thank you for the beauty you are doing, it is very good!

But I followed the steps of installing the project, and here it gave this error:

image

If anyone knows how to proceed, please :) thanks in advance.

Dynamic paths to create models

Hi, good job

I use https://nwidart.com/laravel-modules/v6/introduction to make modules in Laravel

Example: all modules are created into Modules folder, can set custom path to create a model into path Modules/Customer/Entities?? and are same case to create controller with namespace Modules\Customer
image

Another question is can use some iframe or something to put schematics into own view to seem it's into my system?? To see my layout with sidebar, navbar, footer and into content area see schematics

My layout
image

My layout + schematics
image

Thanks

Multiple namespaces

Hello,

eager to try the package.
Actually I have multiple namespaces and can't make schematics to read them. I need to set the config for each individual package. Since some packages make use of others I can't make them appear on the interface.

Can I trick schematics to scaffold a "base" namespace, so it finds the "models" in there?

Edited: The config only affects new models forms etc... the scaffolding is not working right now.

I'm using https://github.com/nWidart/laravel-modules, nothing fancy, just a way to divide the code into components, 100% laravel way. But still...

Stop working after somes tests

Hi, it's an interesting project but it's not working anymore after trying fews things, now i only get this message when i acces to it.

Symfony\Component\ErrorHandler\Error\FatalError
Cannot declare class App\Policies\User because the name is already in use``

Thanks.

php artisan schematics:install failed

LogicException

at vendor/laravel/framework/src/Illuminate/Routing/Route.php:1039
1035| */
1036| public function prepareForSerialization()
1037| {
1038| if ($this->action['uses'] instanceof Closure) {

1039| throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
1040| }
1041|
1042| $this->compileRoute();
1043|

  +32 vendor frames

33 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

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.