get column in relation tables #1606
Unanswered
aivisionbot
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Why do you not want to establish a relation within your Wallet model to User model? If you establish/define joins, then you can of course use a label() method on the column, which will prevent it from trying to be part of the query However I'd still likely to understand the use case behind why you want to abandon Eloquent relations |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for your answer. The relationship between user and wallet model is hasMany() and I could not display this relationship in the table. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i use this query in builder() :
public function builder(): Builder
{
$query = Wallet::query()
->leftJoin('users', 'users.id', '=', 'wallets.holder_id')
->select('wallets.*', 'users.username as username');
Column::make("Username", "username")
->searchable(),
But I encounter this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'wallets.username' in 'field list'
And when I use this code:
Column::make("Username", "users.username")
->searchable(),
I get this error:
Call to undefined relationship [users] on model [Bavix\Wallet\Models\Wallet].
I do not want to use the relationship inside the model; I want to use join in the builder. Please guide me, thank you.
Beta Was this translation helpful? Give feedback.
All reactions