Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 2 years ago.
0

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 ;)

0

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?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.