I really didn't get what you're actually trying to do and if it's really a Laravel or more a JavaScript issue.
But the error means you're trying to access a Model property while accessing actually a relationship instance.
If you use
$portfolio->pcategory->title
you're accessing the pcategory Model itself (so it will be loaded from the database and you can get its values like title and so on).
If you use
$portfolio->pcategory()
you're accessing the relationship between the two models - which is also a queryBuilder object. That means you can do something like
$portfolio->pcategory()->whereTitle('Hello')->get()
So if you remove the () from your example the error should be gone and something should happen. Unfortunately I have no clue if that's what needs to happen for you ;)
What I'm trying to do is get all the categories to show up depending on the portfolio.
so for example. I have portfolio 1 and that portfolio belongs to the cats category.
So I made a list of my portfolios and I need the category that belongs to them.
Does that help?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community