usersuser
usersuser

Reputation: 167

How to fetch a value as a string in laravel?

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'

Upvotes: 0

Views: 456

Answers (1)

Ivan Radojevic
Ivan Radojevic

Reputation: 46

You can use implode...

implode("|",$type);

Upvotes: 1

Related Questions