mtolhuys / laravel-schematics

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reading from a custom path works, however when I try to add a field the POST to `/schematics/models/edit`

mtolhuys opened this issue · comments

Reading from a custom path works, however when I try to add a field the POST to /schematics/models/edit
fails with Exception
"message": "Cannot replace non-existing $fillable",
when hitting the save button.

Drag & drop to sort the new field does not work (can't drop in the list of existing fields)

Originally posted by @cord in #28 (comment)

@cord Model creation was still focused on app_path() so models would be stored there based on the namespace. This caused some weird behavior.

I solved this by adding a 'path' key to 'models' in the config. It will store models specified in the path there. You'll find this in 0.10.2. If you're still experiencing issues I'm curious about the model and it's location. Maybe it's a situation I didn't test yet.

Drag & drop to sort the new field does not work (can't drop in the list of existing fields)

This is due to the fact that it's not (yet) supported to change columns order in migrations through the package.

commented

Just updated:
- Updating mtolhuys/laravel-schematics (0.10.1 => 0.10.2): Downloading (100%)

Then trying this:

Laravel Schematics 2020-03-13 09-02-55

leads to an error bar at the bottom "unprocessable entity" and the response still shows
"message": "Cannot replace non-existing $fillable",

Btw. great package towards a nice roundtrip engineer tool! Currently, I use https://laravelsd.com and https://novapackages.com/packages/cloudstudio/resource-generator which have same nice details you might want to check.

Hi @cord !

Could you maybe share how the class file looks like? Is it's path {app}/csm? I'm having trouble reproducing it. Are you perhaps on Windows as well?

Thanks! Aim is to have a rocksolid tool at v1.0. Interesting shares, I'll look into them!

commented

looks like this - extended from a custom Model class

<?php

namespace Csm;

class Alert extends Model
{
    protected $table = 'alerts';
    public $timestamps = true;

    public function alertRules()
    {
        return $this->belongsToMany('Csm\AlertRule');
    }

    public function alertSubscribers()
    {
        return $this->belongsToMany('Csm\AlertSubscriber');
    }

    public function alertNotifications()
    {
        return $this->hasMany('Csm\AlertNotification');
    }

    public function alertable()
    {
        return $this->morphTo();
    }

   // some more custom functions...)
}


Ah, I see. There is no $fillable. I'll see what I can do about that this evening (since I'm at work right now).

The issue is that you have not made the change in the ORM model to be fillable in the field where you're trying to insert the value to make this work add the following line

protected $fillable = [];

In the array, place the column names in which you're going to store the value.