Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Relationships stopped working #2258

Answered by MeerKatDev
MeerKatDev asked this question in Q&A
Discussion options

  • 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.

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
1 reply
Comment options

your condescending tone is much better I guess.

Answer selected by divine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #2256 on May 20, 2021 21:14.

AltStyle によって変換されたページ (->オリジナル) /