Skip to content
Advertisement

Error Call to a member function attach() on null

I want to create tag system but I have an error “Error Call to a member function attach() on null “. Look at my code

Relationship:

Job.php

JavaScript

Jobservices.php

JavaScript

And I created pivot table

JavaScript

Controller and view

Into controller I tryed attached my services. Look at this.

JavaScript

I think, $request->services is good becouse If i try dd($request->services), it display me this but just in case I’ll show you my view

JavaScript

I don’t know why but it display me an error

Error Call to a member function attach() on null

Do you know what is wrong?

Advertisement

Answer

You should return with the relationship.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement