jeudi 20 décembre 2018

Laravel 5 relationship using a 'JSON' column

Is it possible to use Eloquent to create a relationship in Laravel 5 where the foreign key exists in a field in a JSON column?

If it is, how so?

Example: I have a table called chats with a participantIds column, of a JSON datatype. The JSON format of the data looks like this:

{"creator": "1", "recipient": "2"}

I want to join the users table using those fields to get the participants of the Chats. How do I do that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire