2
I am listing from the data of a query I made with the following code:
$users = DB::table('users')
->join('transportes', 'users.id', '=', 'transportes.user_id')
->join('empresas', 'transportes.id', '=', 'empresas.transporte_id')
->join('motoristas', 'transportes.id', '=', 'motoristas.transporte_id')
->join('caminhoes', 'motoristas.id', '=', 'caminhoes.motorista_id')
->select('caminhoes.cavalo', 'caminhoes.carreta', 'transportes.data_registro')
->whereBetween('transportes.data_registro',['2017-01-01 03:02:46','2018-03-12 11:59:25'])
->get();
And the following result is coming out:
Object(Illuminate Support Collection)#206 (1) { ["items":protected]=> array(15) { [0]=> Object(stdClass)#213 (3) { ["horse"]=> string(7) "AAA-221" ["cart"]=> string(7) "BBB-196" ["data_record"]=> string(19) "2018-03-06 22:41:07" } [1]=> Object(stdClass)#209 (3) { ["horse"]=> string(7) "AAA-221" ["cart"]=> string(7) "BBB-196" ["data_record"]=> string(19) "2018-03-06 22:41:07" } [2]=> Object(stdClass)#212 (3) { ["horse"]=> string(7) "AAA-221" ["cart"]=> string(7) "BBB-196" ["data_record"]=> string(19) "2018-03-06 22:41:07" } [3]=> Object(stdClass)#215 (3) { ["horse"]=> string(7) "AAA-489" ["cart"]=> string(7) "BBB-213" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [4]=> Object(stdClass)#208 (3) { ["horse"]=> string(7) "AAA-489" ["cart"]=> string(7) "BBB-213" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [5]=> Object(stdClass)#207 (3) { ["horse"]=> string(7) "AAA-388" ["cart"]=> string(7) "BBB-309" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [6]=> Object(stdClass)#210 (3) { ["horse"]=> string(7) "AAA-388" ["cart"]=> string(7) "BBB-309" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [7]=> Object(stdClass)#216 (3) { ["horse"]=> string(7) "AAA-448" ["cart"]=> string(7) "BBB-209" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [8]=> Object(stdClass)#217 (3) { ["horse"]=> string(7) "AAA-448" ["cart"]=> string(7) "BBB-209" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [9]=> Object(stdClass)#218 (3) { ["horse"]=> string(7) "AAA-401" ["cart"]=> string(7) "BBB-271" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [10]=> Object(stdClass)#219 (3) { ["horse"]=> string(7) "AAA-401" ["cart"]=> string(7) "BBB-271" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [11]=> Object(stdClass)#220 (3) { ["horse"]=> string(7) "AAA-187" ["cart"]=> string(7) "BBB-422" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [12]=> Object(stdClass)#221 (3) { ["horse"]=> string(7) "AAA-187" ["cart"]=> string(7) "BBB-422" ["data_record"]=> string(19) "2018-02-27 01:52:54" } [13]=> Object(stdClass)#222 (3) { ["horse"]=> string(7) "AAA-276" ["cart"]=> string(7) "BBB-438" ["data_record"]=> string(19) "2017-12-18 20:35:44" } [14]=> Object(stdClass)#223 (3) { ["horse"]=> string(7) "AAA-276" ["cart"]=> string(7) "BBB-438" ["data_record"]=> string(19) "2017-12-18 20:35:44" } } }
i wish I could take the data separately. Example: take only the column 'horses' and list?
I would remove from select 'trucks.cart', 'transport.data_registration' if you are not using and Join in companies.
– guastallaigor
This solution is bad, it brings data from the table that you do not need (or that at least you did not report the utility). No
select
only bring what you will actually use.– novic
All right, thank you! I’m making the adjustments :D
– GgMamedio
I need all this data, I did according to the table you asked me to generate.
– GgMamedio