Laravel pluck but combining first name + last name for select
问题 Using select2 with a Laravel / Vue project and need to return JSON in the following format: [ { id: 0, text: 'enhancement' }, { id: 1, text: 'bug' } ] In Laravel I know I can use pluck to create my list data e.g. for customers: $customers = Customer::pluck('id', 'first_name'); But Want to return the id and first name + last name as a single name. How can I do this? 回答1: Have you tried using Accessors? https://laravel.com/docs/5.4/eloquent-mutators#defining-an-accessor I have not tested it but