Skip to content

Can select only necessary columns via byHash #139

@addeeandra

Description

@addeeandra

Is your feature request related to a problem? Please describe.

Let's say that I had a table with 20 columns. The Model::byHash($hash) is getting all 20 columns by default, and hide columns from $hidden attribute. I often face a scenario where I need to get only 1 or 2 column for a table via Model::byHash($hash).

It's currently achievable with: Model::select('id', 'email')->byHash($hash)->first();. Two problems here:

  1. Loss of type-safety.
  2. Loss of conciseness, we can make it better.

Describe the solution you'd like

Capability to use Model::byHash($hash, $columns), Model::byHashOrFail($hash, $columns)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions