Closed Krofek closed 4 years ago
Can you post minimal piece of code.
I edited the issue post.
After upgrading homestead to the lastest version and vagrant box to the latest version also, the error changed to
Type of Illuminate\Database\Eloquent\Relations\Pivot::$guarded must be array (as in class Illuminate\Database\Eloquent\Model)
It gets fixed by editing line 24 on:
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php
Since the Model class has the Illuminate\Database\Eloquent\Concerns\GuardsAttributes
on line 21 the guarded property is array typed.
Question, since the $guarded property is defined in Model, does it need to be defined again in the Pivot model?
My guess is that you're using a PHP 7.4 property type for guarded. You can't do this for any properties inherited from framework classes because any properties from the framework aren't typed yet because we still need to support PHP 7.2 and 7.3
My guess is that you're using a PHP 7.4 property type for guarded. You can't do this for any properties inherited from framework classes because any properties from the framework aren't typed yet because we still need to support PHP 7.2 and 7.3
Is there any trick to bypass this problem? I have the same problems.
No there isn't.
I updated my laravel 6 project and I got this error on all my models. I fixed them but I got this error on laravel's own models.
Type of Illuminate\Database\Eloquent\Relations\Pivot::$guarded must be array (as in class Illuminate\Database\Eloquent\Model)
Type of Illuminate\Notifications\DatabaseNotification::$table must be string (as in class Illuminate\Database\Eloquent\Model)
Laravel version: 6.20.16 php version: 7.4 using with ubuntu/nginx
the issue happens on:
Inserting, updating intermediate tables works. Whenever I try to eager load with
->with()
or->load()
I get the error on the Pivot class.I think it's a php 7.4 issue, since it worked fine on 7.3
edit:
App\Models\Grow
App\Models\Watering
App\Models\Plant
App\Http\Controllers\GrowController
I dies when I try to load 'waterings.nutrients'
or the second case is:
App\Repositores\GrowRepository
Here it dies when trying to load 'plants.waterings'