You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Loss of type-safety.
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)
The text was updated successfully, but these errors were encountered:
This could be a fine addition if signature of static byHash/byHashOrFail had a default of ['*'] columns. This would make it not break existing applications and it would be consistent with find/findOrFail.
The question I just have is what do you mean by "loss of type-safety". What is a difference in this context between Model::byHash($hash) and Model::query()->select(['*'])->byHash($hash)->first()?
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 viaModel::byHash($hash)
.It's currently achievable with:
Model::select('id', 'email')->byHash($hash)->first();
. Two problems here:Describe the solution you'd like
Capability to use
Model::byHash($hash, $columns)
,Model::byHashOrFail($hash, $columns)
The text was updated successfully, but these errors were encountered: