Eloquent returning field and value

-1

My select is returning the field and the value of the id that is in the table and I need to return only the value, how do I do it?

$id = DB::table('participantes')
        ->select('id')
        ->orderBy('id','DESC')
        ->take(1)
        ->get();

Error returned

  SQLSTATE [22007]: Invalid datetime format: 1366 Incorrect integer value: '[{"id": 173}]' for column 'participant_id' at row 1 (SQL: insert into participantes ( opcao_id ,% (%), questao_id ) values (291, 84, [{"id": 173}]))

    
asked by anonymous 25.10.2018 / 20:31

1 answer

0

Have you tried to get only the id of the result instead of using the array?

$result = DB::table('participantes')
        ->select('id')
        ->orderBy('id','DESC')
        ->first();

$id = $result->id;
    
25.10.2018 / 20:39