someonefamous / laravel-findby
Extended 'find' functionality for Eloquent (Laravel).
Installs: 10 482
Dependents: 3
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 2
pkg:composer/someonefamous/laravel-findby
Requires
- php: >=7
- illuminate/support: >=5
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-10-19 23:42:23 UTC
README
Extended 'find' functionality for Eloquent (Laravel).
Enables writing queries like $that_smith_guy = User::findByLastName('Smith'), rather than the longer, but equivalent $that_smith_guy = User::where('last_name', 'Smith')->first().
Also, $all_the_bobs = User::findAllByFirstName('Bob') rather than $all_the_bobs = User::where('first_name', 'Bob')->get().
The command can be used for any arbitrary [snake-cased] field name. e.g. Item::findByArbitraryFieldName('example') is functionaly equivalent to Item::where('arbitrary_field_name', 'example')->first().
To use, simply add use SomeoneFamous\FindBy\Traits\FindBy; to any Eloquent model:
...
use SomeoneFamous\FindBy\Traits\FindBy;
class Thing extends Model
{
use FindBy;
...