Home > Blockchain >  Laravel | Query with select
Laravel | Query with select

Time:03-14

I have a query and use ->pluck and i see my result

[22]

$ferias = feria::where('id_funcionario', '=', $userid)->pluck('n_ferias_disponiveis');

I can see my result without [] ? For exemple use de select 'n_ferias_disponiveis', but how do you use select in the above query?

CodePudding user response:

$ferias = Feria::select('id_funcionario')->where('id_funcionario', '=', $userid)->get();

Pluck is collection function you should first get then you can use pluck method like:

$ferias = Feria::select('id_funcionario')->where('id_funcionario', '=', $userid)->get()->pluck('id_funcionario');
  • Related