Closed zachweix closed 4 months ago
This is how the virtualcolumn package works, if you think it should be changed you can send a PR there.
If possible, can you clarify? When I say that id is guarded, why should that change if a column gets added to the data column?
At the moment, $guarded
simply needs to be an empty array, the package expects taht. If you'd want to add support for guarded columns, see the virtualcolumn repo and submit a feature request or a PR there.
Bug description
I tried creating a new tenant and I couldn't specify the db name if the guarded array was changed on my tenant model
Steps to reproduce
Create a custom tenant model Use incrementing ids in the database and set id_generator to null in the config file run
App\Models\Tenant::create(['tenancy_db_name' => 'acme']);
Note that the tenancy_db_name is saved in the database as "acme" Addprotected $guarded = ['id'];
to the tenant model runApp\Models\Tenant::create(['tenancy_db_name' => 'acme2']);
Note that the tenancy_db_name is not actually set when saving and therefore the tenancy_db_name is created by defaultOn a separate note, in the first scenario I also noticed that created_at and updated are saved in the data column, not their own columns until I added them to the getCustomColumns functions, though I think that's a separate bug
Expected behavior
The second database created should have been called acme2
Laravel version
11.15.0
stancl/tenancy version
3.8.4