lundi 15 octobre 2018

Query a list of value of a specific column - Laravel

I'm trying to query a list as an array directly out of a table of my database without having to create another foreach loop and construct one myself.


I try

return Response::json(Skill::select('name')->get());

I get

[{"name":"Vagrant"},{"name":"Docker"},{"name":"Gulp"},{"name":"Heroku"},{"name":"RequireJS"},{"name":"AngularJS"},{"name":"Composer "},{"name":"NPM"},{"name":"MySQL"},{"name":"Sublime Text"},{"name":"Laravel"},{"name":"PyCharm"},{"name":"Mac OS X"},{"name":"Windows"},{"name":"Ubuntu"},{"name":"Cent OS"},{"name":"Photoshop"},{"name":"Illustrator"},{"name":"MobaXTerm"},{"name":"Terminal"},{"name":"iMovie"},{"name":"Final Cut"},{"name":"GitHub"},{"name":"BitBucket"},{"name":"Selenium"},{"name":"Python"},{"name":"Bower"},{"name":"Sass"},{"name":"Digital Ocean"},{"name":"Linode"},{"name":"Siteground"},{"name":"Go Daddy"},{"name":"Shopify"},{"name":"Facebook"},{"name":"Twitter"},{"name":"Salesforce"},{"name":"OAuth 2.0"},{"name":"SAML 2.0"},{"name":"OpenID Connect"},{"name":"PostgreSQL"},{"name":"Bash"},{"name":"PHP"},{"name":"Google Map"},{"name":"Google Translation"},{"name":"Instagram"},{"name":"LESS"},{"name":"Geolocation API"},{"name":"Xcode"},{"name":"Atom"},{"name":"Webpack"},{"name":"AWS Console"},{"name":"Secure Shell"},{"name":"Node"},{"name":"Yarn"},{"name":"Pod"},{"name":"EC2"},{"name":"Amazon ECS"},{"name":"S3"},{"name":"Amazon RDS"},{"name":"Camtasia"},{"name":"Core Data"},{"name":"Realm"},{"name":"VS Code"},{"name":"TextMate"},{"name":"TextWrangler"},{"name":"Laravel Elixir"},{"name":"Virtual Machine"},{"name":"Open  Stack"},{"name":"Redis"},{"name":"Local Storage"},{"name":"Protractor"},{"name":"Jest"},{"name":"Mocha"},{"name":"Chai"},{"name":"SinonJS"},{"name":"AWS"},{"name":"HTML"},{"name":"CSS"},{"name":"Javascript"},{"name":"Sketch"},{"name":"iOS"},{"name":"Express"},{"name":"Angular"},{"name":"React Native"},{"name":"jQuery"},{"name":"Nginx"},{"name":"Apache"},{"name":"PayPal"},{"name":"Square "},{"name":"Disqus"},{"name":"YouTube"},{"name":"Swagger"},{"name":"GitLab"},{"name":"Amazon ECR "},{"name":"Jira"},{"name":"Trello "},{"name":"Evernote "},{"name":"Confluence "},{"name":"Word"},{"name":"CodeBox"},{"name":"Markdown"},{"name":"Noteability"},{"name":"Kamar"},{"name":"Jasmine"},{"name":"Swift"},{"name":"Coda"},{"name":"Postman"},{"name":"Wireshark"},{"name":"Transmit"},{"name":"WinSCP"},{"name":"Navicat Premium"},{"name":"Kaleidoscope"},{"name":"Mind Note "},{"name":"Divvy"},{"name":"Duet"},{"name":"Draw.io"},{"name":"Google Draw"},{"name":"VMWare Fusion "},{"name":"Virtualbox"},{"name":"QuickBooks"},{"name":"Chat.io"},{"name":"FusionCharts"},{"name":"Google Chart"},{"name":"J Player"},{"name":"CKEditor"}]

I was trying to get these

["Vagrant","Docker","Gulp","Heroku","RequireJS","AngularJS","Composer ","NPM","MySQL","Sublime Text","Laravel","PyCharm","Mac OS X","Windows","Ubuntu","Cent OS","Photoshop","Illustrator","MobaXTerm","Terminal","iMovie","Final Cut","GitHub","BitBucket","Selenium","Python","Bower","Sass","Digital Ocean","Linode","Siteground","Go Daddy","Shopify","Facebook","Twitter","Salesforce","OAuth 2.0","SAML 2.0","OpenID Connect","PostgreSQL","Bash","PHP","Google Map","Google Translation","Instagram","LESS","Geolocation API","Xcode","Atom","Webpack","AWS Console","Secure Shell","Node","Yarn","Pod","EC2","Amazon ECS","S3","Amazon RDS","Camtasia","Core Data","Realm","VS Code","TextMate","TextWrangler","Laravel Elixir","Virtual Machine","Open  Stack","Redis","LocalStorage","Protractor","Jest","Mocha","Chai","SinonJS","AWS","HTML","CSS","Javascript","Sketch","iOS","Express","Angular","React Native","jQuery","Nginx","Apache","PayPal","Square ","Disqus","YouTube","Swagger","GitLab","Amazon ECR ","Jira","Trello ","Evernote ","Confluence ","Word","CodeBox","Markdown","Noteability","Kamar","Jasmine","Swift","Coda","Postman","Wireshark","Transmit","WinSCP","Navicat Premium","Kaleidoscope","Mind Note ","Divvy","Duet","Draw.io","Google Draw","VMWare Fusion ","Virtualbox","QuickBooks","Chat.io","FusionCharts","Google Chart","J Player","CKEditor"]


Questions

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire