lundi 24 juin 2019

In eloquent fetching data in fieldname=>fieldvalue keys

In laravel 5.8 making request

        $searchResultsArray = SearchResult
            ::getBySourceId($next_sourceId['source_id'])
            ->select( 'field', 'value' )
            ->get()
            ->toArray();

I got resulting rows like :

$searchResultsArray::Array
(
    [0] => Array
        (
            [field] => Id
            [value] => 302530
        )

    [1] => Array
        (
            [field] => Domain
            [value] => site.com
        )

If there is a way to get array of fieldname=>fieldvalue keys, like

Id => 302530 
Domain=> site.com

without additive foreach block in my code?

If yes how?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire