Bez_Haile 2020-05-12 23:15:40
Hello guys i have a few questions, to discuss, is there any one who is willing to…
imsus_k 2020-05-12 23:15:57
Yes
Bez_Haile 2020-05-12 23:16:30
imsus_k 2020-05-12 23:15:57
Yes
Okay am building a b2b site
Bez_Haile 2020-05-12 23:16:43
And With a search engine
imsus_k 2020-05-12 23:17:01
Okey
Bez_Haile 2020-05-12 23:17:39
So i have relationship with hasmany
Bez_Haile 2020-05-12 23:18:27
I have 5 tables
imsus_k 2020-05-12 23:18:43
Okey
Bez_Haile 2020-05-12 23:18:45
Now this is my question
imsus_k 2020-05-12 23:19:19
You want to join and get result according to that
Bez_Haile 2020-05-12 23:20:11
imsus_k 2020-05-12 23:19:19
You want to join and get result according to that
Yeah join and fetch, “as per the user_id”
Bez_Haile 2020-05-12 23:20:59
Did you get it?
imsus_k 2020-05-12 23:21:17
So you can use model eloquent to make relationship by foreign key
imsus_k 2020-05-12 23:21:24
Or you can use manually query
Bez_Haile 2020-05-12 23:21:38
imsus_k 2020-05-12 23:21:17
So you can use model eloquent to make relationship by foreign key
I have already done that
imsus_k 2020-05-12 23:21:52
Then what is error ot issue
imsus_k 2020-05-12 23:21:54
Or
Bez_Haile 2020-05-12 23:22:22
My question is on the search engine
Bez_Haile 2020-05-12 23:22:37
A person search and item
Bez_Haile 2020-05-12 23:23:17
Then it will display the items, owner, and contact phone number
Bez_Haile 2020-05-12 23:24:29
Displaying all the item from different tables by matching the user_id(the owner of that item)
imsus_k 2020-05-12 23:26:09
You enter in search box user id
Bez_Haile 2020-05-12 23:26:54
imsus_k 2020-05-12 23:26:09
You enter in search box user id
No, you are going to search and item
imsus_k 2020-05-12 23:27:42
Okey on the basis of items owner and contacy phone number you want
Bez_Haile 2020-05-12 23:28:06
imsus_k 2020-05-12 23:27:42
Okey on the basis of items owner and contacy phone number you want
Yeah
Bez_Haile 2020-05-12 23:28:50
Search item
Get… owners, contact, and amount of the item left
Get… owners, contact, and amount of the item left
imsus_k 2020-05-12 23:29:28
Okey
imsus_k 2020-05-12 23:29:34
Wiat
imsus_k 2020-05-12 23:29:35
Wait
imsus_k 2020-05-12 23:29:37
Telling
Bez_Haile 2020-05-12 23:29:56
Okay 😊
imsus_k 2020-05-12 23:31:53
From item table you can easily get owner details
This item belongsTo this user from items side
imsus_k 2020-05-12 23:32:20
Price on same table or different table
Bez_Haile 2020-05-12 23:32:52
imsus_k 2020-05-12 23:32:20
Price on same table or different table
Same table
Bez_Haile 2020-05-12 23:34:14
imsus_k 2020-05-12 23:31:53
From item table you can easily get owner details
This item belongsTo this user from items side
Eloquent relationship?
imsus_k 2020-05-12 23:34:16
Bez_Haile 2020-05-12 23:32:52
Same table
Then items match you will get prince and by item has userid so you get owner details
imsus_k 2020-05-12 23:35:03
Bez_Haile 2020-05-12 23:34:14
Eloquent relationship?
In eloquent Items model make a function owner
And return with belongsTo
Bez_Haile 2020-05-12 23:35:38
imsus_k 2020-05-12 23:35:03
In eloquent Items model make a function owner
And return with belongsTo
And return with belongsTo
I did the belongsTo, on my users model
Bez_Haile 2020-05-12 23:36:07
imsus_k 2020-05-12 23:34:16
Then items match you will get prince and by item has userid so you get owner details
Please a little be hint
Bez_Haile 2020-05-12 23:36:34
What shall i do in my controller
imsus_k 2020-05-12 23:36:46
Bez_Haile 2020-05-12 23:35:38
I did the belongsTo, on my users model
Use table return hasmany because owner have many items
imsus_k 2020-05-12 23:37:13
Bez_Haile 2020-05-12 23:36:34
What shall i do in my controller
Have you ever used with function
Bez_Haile 2020-05-12 23:37:39
imsus_k 2020-05-12 23:37:13
Have you ever used with function
Yeah ofcourse
Bez_Haile 2020-05-12 23:37:56
I have simpleSeach function
Bez_Haile 2020-05-12 23:38:24
How can i pass in that function all of this
Bez_Haile 2020-05-12 23:38:54
imsus_k 2020-05-12 23:36:46
Use table return hasmany because owner have many items
I did 😊
imsus_k 2020-05-12 23:39:17
So first make function user in items model and return belongsto value from there
imsus_k 2020-05-12 23:39:48
If you primary key forign ki not accoring to laravel norms then pass manually
Bez_Haile 2020-05-12 23:40:23
imsus_k 2020-05-12 23:39:17
So first make function user in items model and return belongsto value from there
Look the relationship part is done, its working fine
Bez_Haile 2020-05-12 23:40:48
The hasMany, belongsTo are done