Skip to content

Using Presenter with lists() method #24

Open
@bandgeekndb

Description

@bandgeekndb

I am attempting to use the Laracasts Presenter with the lists() method like so:

$physicians = Employee::physician()->get()->lists(<formattedName>, 'id');
// <formattedName> would be the column name of the employee's name.
// Since it is stored as first and last separately, I use the Laracasts Presenter to present the concatenated full name.

I have a namespaced Employee model, and a query scope to filter the query results. My issue is, without calling the present() method, I can't access my presenter method for formatting the name. I can not find a place to insert the present() method that makes the lists() method work properly. Has anyone done this before?

My current workaround was setting a custom getter on the model to get the concatenated full name that way, but I would like to use the presenter method I already wrote if that is possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions