laravel-schematics icon indicating copy to clipboard operation
laravel-schematics copied to clipboard

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

Open mtolhuys opened this issue 4 years ago • 6 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 https://github.com/mtolhuys/laravel-schematics/issues/28#issuecomment-598145586

mtolhuys avatar Mar 12 '20 19:03 mtolhuys

@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.

mtolhuys avatar Mar 12 '20 19:03 mtolhuys

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.

cord avatar Mar 13 '20 08:03 cord

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!

mtolhuys avatar Mar 13 '20 09:03 mtolhuys

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...)
}


cord avatar Mar 13 '20 09:03 cord

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).

mtolhuys avatar Mar 13 '20 09:03 mtolhuys

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.

AsjidAle avatar Mar 04 '24 14:03 AsjidAle