This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

TJMB
TJMB

I'm using the Builder plugin to create a backend interface for managing a restaurant menu. I need to pull together data from my website's database using a few different queries and then returning them as one result to loop through. Some of the fields are jsonable and store data from Repeaters. I attempted using a Db query in my scope, like so:

public function scopeLunchMenu($query) {
    $salads = Db::table($this->table)->where('category_lunch', 'Salads');
    $soups = Db::table($this->table)->where('category_lunch', 'Soups');
    $mainplate = Db::table($this->table)->where('category_lunch', 'Main Plate');

    return Db::table($this->table)->where('category_lunch', 'Small Plates')
        ->union($salads)
        ->union($soups)
        ->union($mainplate);
}

However, that returns the jsonable field values as strings and I can't loop through them.

What's the proper way to do the above as a query scope for use with the Builder plugin?

I hope this question makes sense and that I've included all the info that I need to here. Thanks!

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.