Support the ongoing development of Laravel.io →
Requests Database Views
Last updated 1 year ago.
0

Try $user->profile->userStatus()

0

dd($user->profile);

results into

Profile {#188 ▼ #table: "posts" #fillable: array:3 [▼ 0 => "title" 1 => "post_pic" 2 => "post_story" ] #hidden: [] #connection: null #primaryKey: "id" #perPage: 15 +incrementing: true +timestamps: true #attributes: array:8 [▶] #original: array:8 [▶] #relations: [] #visible: [] #appends: [] #guarded: array:1 [▶] #dates: [] #dateFormat: null #casts: [] #touches: [] #observables: [] #with: [] #morphClass: null +exists: true +wasRecentlyCreated: false }

I can see there is no relationship set

Last updated 8 years ago.
0

RossTsachev said:

Try $user->profile->userStatus()

it was my tyop here. I still can't fetch data from profile table.

0
dd($user->profile);

There should be no relationship here. Status is not a relationship. It's a field in profile so you shouldn't even need to create a function for that. You can just access it by doing

dd($user->profile->status);
Last updated 8 years ago.
0

thomastkim said:

dd($user->profile);

There should be no relationship here. Status is not a relationship. It's a field in profile so you shouldn't even need to create a function for that. You can just access it by doing

dd($user->profile->status);

I understand it now. Thanks for explaining. anyway dd($user->profile->status) returns Null.

0

If you dd($user->profile), you said that you get this, correct?

Profile {#188 ▼ #table: "posts" #fillable: array:3 [▼ 0 => "title" 1 => "post_pic" 2 => "post_story" ] #hidden: [] #connection: null #primaryKey: "id" #perPage: 15 +incrementing: true +timestamps: true #attributes: array:8 [▶] #original: array:8 [▶] #relations: [] #visible: [] #appends: [] #guarded: array:1 [▶] #dates: [] #dateFormat: null #casts: [] #touches: [] #observables: [] #with: [] #morphClass: null +exists: true +wasRecentlyCreated: false }

Can you open up attributes (click on it when you dd the output) and tell us what you see? Status should be listed under attributes.

0

This is totally weird. I just noticed that here in the dd output. table is "posts". It should be "profile" table. I deleted postController and post model and post routes to see if there was any conflict. But there isn't. It is still showing posts table.

0

Can you post the code on how you are retrieving these models?

0

I've already posted both models here. Do you want to see controller files?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

apurva2342 apurva2342 Joined 17 Sep 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.