I have one database query which returns collection, i want to fetch the value instead of fetching collection or array, please help me to achieve this thing
$type=DB::table('users')->where('id',$value)->pluck('role')->toArray();
Actual Result : ['admin'] //array
Expected Result : $type='admin'
$typeto be in the result, where does that come from?->toArray()returns ... an array, have you tried echoing its first(only) element?->toArray()[0]I presume.