V
V
Vitaly2018-06-05 17:07:08
ORM
Vitaly, 2018-06-05 17:07:08

Laravel. How to join values ​​from 2 columns, 2 different tables)?

The programs table has a json_stream column. With the value m - I ["1stream","2stream"].
attach the channels table to the programs table, in which there is a stream column, with the value m - ["3stream","4stream"].
I make a selection like this
$program = Program::with('channel')->first();
Is it possible to combine these fields at the ORM level to get

$program->all_streams ==  ["1stream","2stream","3stream","4stream"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rikcon, 2018-06-05
@kiukishenkaec

https://laravel.com/docs/5.6/eloquent-mutators
In fact, as I understand it, you need an Accessor.
In the model you create it and in the function you can "shrink" the array as you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question