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
RossTsachev said:
Try $user->profile->userStatus()
it was my tyop here. I still can't fetch data from profile table.
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);
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.
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.
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.
I've already posted both models here. Do you want to see controller files?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community