1

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

2
  • This does not make any sense at all... You could as well just write Mainenance as a string... ( You are querying for tabnames = Maintenance and then want to 'pluck' the tabname... ? ) Aug 9, 2016 at 16:40
  • I have different tabnames and information per tab that i want to display. I use the colum tabname and the actual tabname in this case "maintenance" so that i make sure i am picking and retrieving the right information for the right tabname. Alexey Mezenin give me what i was looking for.
    – RockNova
    Aug 11, 2016 at 0:59

1 Answer 1

5

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] }}
1
  • 1
    Thank you very much that workt. Pluck isn't really a most i am pretty new to laravel so i am just using what i kind of know.
    – RockNova
    Aug 9, 2016 at 14:25

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.