0
votes

I'm getting the error, but I can't find why?

Call to undefined method Illuminate\Database\Query\Builder::domains()

The error appears in this two lines of my controller:

$tags = Domains::query()->findOrFail($id);
$tags->domains()->attach($all_tags);

I'm using a pivot table, that's my belongsToMany() relation:

public function domains() { return $this->belongsToMany('App\Models\technical\Domains', 'domain_tag', 'id', 'domains_id'); }

Does anyone see why?

1
You are calling model Domain and looking for it's domains()? - Ivanka Todorova

1 Answers

0
votes

It looks like you took wrong class:

$tags = Domains::query()->findOrFail($id);

I'm guessing that You want to take:

$tags = Tag::query()->findOrFail($id);

Or something like this