Why when I use this form of retriving data from the database:
{{$homecontent->where('tabname', 'Maintenance')->pluck('tabname')}}
Laravel shows me the data with square brackets and quotes like this on my page:
["Maintenance"]
I just want it to give me back Maintenance
pluck()
generates a collection (looks like an array here) and with {{ }}
you're just printing it's content. That's why you see something like ["Content"]
You could do something like this to print Maintenance
:
{{ $homecontent->where('tabname', 'Maintenance')->first()->tabname }}
Or, if for some reason you need to use pluck()
:
{{ $homecontent->where('tabname', 'Maintenance')->pluck('tabname')->toArray()[0] }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.