I am using the Spatie / Schemaless Attributes package which has a schema macro for adding a schemaless attributes column:
Blueprint::macro('schemalessAttributes', function (string $columnName = 'schemaless_attributes') {
return $this->json($columnName)->nullable();
});
After adding it to my migration like this:
Schema::table('offers', function (Blueprint $table) {
$table->schemalessAttributes('extra_attributes');
});
And setting up my model as described in the package:
protected function casts(): array
{
return [
'extra_attributes' => SchemalessAttributes::class
];
}
public function scopeWithExtraAttributes(): Builder
{
return $this->extra_attributes->modelScope();
}
I run the helper code generation but the extra_attributes attribute is not added to the model attributes list:
However, if I add the column in my migration without using the macro, everything works as expected without changing anything else:
Schema::table('offers', function (Blueprint $table) {
$table->json('extra_attributes')->nullable();
});
Plugin version
8.2.5.242
Operating system
MacOS
Steps to reproduce
Register a macro in a service provider
Blueprint::macro('testMacro', function (string $columnName) {
return $this->string($columnName)->nullable();
});
Add 2 columns to a model, one using the macro and one directly adding the type in the migration:
Schema::table('test_models', function (Blueprint $table) {
$table->testMacro('test_column');
$table->string('test_column2');
});
Run the helper code generator
Try to use the test_column somewhere in the code:
public function testing()
{
$testModel->test_column;
}
Try to navigate to the property by using the middle mouse button or cmd/ctrl + left click. It will not work and, in some cases, you might even see it highlighted for being accessed via magic methods:
Bug description
I am using the Spatie / Schemaless Attributes package which has a schema macro for adding a
schemaless attributes
column:After adding it to my migration like this:
And setting up my model as described in the package:
I run the helper code generation but the
extra_attributes
attribute is not added to the model attributes list:However, if I add the column in my migration without using the macro, everything works as expected without changing anything else:
Plugin version
8.2.5.242
Operating system
MacOS
Steps to reproduce
test_column
somewhere in the code:However, the
test_column2
is working as expected:Relevant log output
No response