-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Relationships stopped working #2258
-
- Laravel-mongodb Version: 3.8.3
- PHP Version: 7.4.19
- Database Driver & Version: mongodb/mongodb 1.8.0
Description:
relationships, like belongsTo and hasMany, stopped working overnight
Steps to reproduce
No idea tbh, cannot find the culprit.
Expected behaviour
The relationships should give the related entities.
Actual behaviour
The model is very simple. 4 attributes in $fillable
and the hasMany
relation, everything very standard. They're just small models that are used for static data.
I tried to remove changes done that could influence the model (I added some fields in $fillable
), but it didn't help the situation.
Beta Was this translation helpful? Give feedback.
All reactions
It's hard to guess for me too, so I'm asking here because MAYBE, but only MAYBE, someone (that wrote the code of this library) could at least give me hints on where I could check, instead of telling me "Pretty vague and incomplete information." - so here the more complete available information:
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Jenssegers\Mongodb\Eloquent\Model;
class SubProduct extends Model
{
use CrudTrait;
protected $table = 'subproducts';
protected $guarded = ['id'];
protected $fillable = [
'code',
'desc',
'object',
...
];
public static function boot()
{
parent::boot();
static::deleting(funct...
Replies: 1 comment 1 reply
-
It's hard to guess for me too, so I'm asking here because MAYBE, but only MAYBE, someone (that wrote the code of this library) could at least give me hints on where I could check, instead of telling me "Pretty vague and incomplete information." - so here the more complete available information:
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Jenssegers\Mongodb\Eloquent\Model;
class SubProduct extends Model
{
use CrudTrait;
protected $table = 'subproducts';
protected $guarded = ['id'];
protected $fillable = [
'code',
'desc',
'object',
...
];
public static function boot()
{
parent::boot();
static::deleting(function($obj) {
... }
}
public function product()
{
return $this->belongsTo(Product::class);
}
...
while Product is practically the same, without boot
and with
public function subproduct()
{
return $this->hasMany(SubProduct::class);
}
Tons more of information, right? That's all I have.
Beta Was this translation helpful? Give feedback.
All reactions
-
your condescending tone is much better I guess.
Beta Was this translation helpful? Give feedback.