mardi 15 décembre 2015

How to get Laravel Collection from Builder?

I want to get all results from two tables akcii, feeds and after search throw them (now query just returns all records without any conditions for search), here is the query (mysql):

DB::query('SELECT id, title, text FROM (
        SELECT id, title, text FROM `akcii` UNION ALL
        SELECT id, title, body FROM `feeds`
    ) temp_table
        ORDER BY `id` desc
        LIMIT 0, 10')

Results are exacly that I need but after I can't convert it Collection? If I call ->get() method I'm getting an error:

QueryException in Connection.php line 651:
SQLSTATE[HY000]: General error: 1096 No tables used (SQL: select *)

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire