Table with accessor content
Hi, in a table, I want to show the data contained in an accessor of the User model (multidimensional array). How can I do it?
Alternatively I have been trying with Sushi, but the problem is that I can't pass the User ID to the Shushi model.
5 Replies
Do you need to use query()?
normally it would work like this
Ok, thanks, but that's not the issue, the problem is that if I use User::find(1), the "balance" is a multidimensional array, could I use that array for the table?
The other option, using Shushi, I don't know how to pass the User id to the model (in the model getRows() I have a funcion call that needs the User id)
I am not sure if i understand you, but the balance table has a array? and you want that array assigneed to a user ? in this case user 1
In User:
public function getBalanceAttribute()
{
return GetBalance::run($this->id);
}
It returns (example):
[ [ 'description' => 'Buy XXXX', amount => 100 ], [ 'description' => 'Buy YYYY', amount => 200 ] ]
I want that the Table show that balance information
Just make a relation between the 2 models that works