suppose we have an Object that accept some value as array that is separated by comma:
$keyboard = new Keyboard(
['value1'],
['value2'],
['value3'],
['value4']
);
Now I want to fetch some value from database via a loop and send them finally to that object. but I do not know how can I collect them and send a comma separated list of them.
I write this code But can not get appropriate result from it:
$brands = Option::with('translations')->whereHas('attribute', function ($query) {
$query->where('type', '=', 'brand');
})->get();
$titles = [];
foreach ($brands as $key => $brand) {
$titles [] = array($brand->title_fa);
}
$keyboard = new Keyboard(
$titles
);
varidicparams to receive an N number arguments? or are you receiving an string comma separated?