You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Additional context
When adding
public null|string $routing = null;
to the model the problem is solved but why is this necessary? Also the documentation does not say anything about it.
@matchish I now see that one of our configuration causes this issue to happen:
final class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Model::preventLazyLoading(!$this->app->isProduction()); Model::preventAccessingMissingAttributes();
Model::preventSilentlyDiscardingAttributes();
}
}
We use Model::preventAccessingMissingAttributes(); to prevent magical bugs in our application. This exception shows us that the package is trying to access a missing attrubute.
Describe the bug
MissingAttributeException error appears when running php artisan scout:import
final class Track extends Model
{
use HasFactory;
use Searchable;
use SoftDeletes;
}
Importing [App\Models\Track]
Create write index
2/5 [⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬➤⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬] 40%
Illuminate\Database\Eloquent\MissingAttributeException
The attribute [routing] either does not exist or was not retrieved for model [App\Models\Track].
at vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:472
To Reproduce
Steps to reproduce the behavior:
final class Track extends Model
{
use HasFactory;
use Searchable;
use SoftDeletes;
}
php artisan scout:import
The attribute [routing] either does not exist or was not retrieved for model [App\Models\Track].
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:452
Illuminate\Database\Eloquent\Model::throwMissingAttributeExceptionIfApplicable("routing")
2 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2227
Illuminate\Database\Eloquent\Model::getAttribute("routing")
3 vendor/matchish/laravel-scout-elasticsearch/src/ElasticSearch/Params/Bulk.php:47
Illuminate\Database\Eloquent\Model::__get("routing")
Expected behavior
model is synced to index
Additional context
When adding
public null|string $routing = null;
to the model the problem is solved but why is this necessary? Also the documentation does not say anything about it.
change possible causing this issue: https://github.com/matchish/laravel-scout-elasticsearch/pull/91/files
Version
laravel/framework: v10.8.0
laravel/scout: v10.1.1
matchish/laravel-scout-elasticsearch: v7.2.1
The text was updated successfully, but these errors were encountered: