PHPackages                             jasonmccreary/laravel-additions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jasonmccreary/laravel-additions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jasonmccreary/laravel-additions
===============================

WIP

v0.4.0(7mo ago)186072[1 PRs](https://github.com/jasonmccreary/laravel-additions/pulls)MITPHPPHP ^8.2CI failing

Since Mar 21Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/jasonmccreary/laravel-additions)[ Packagist](https://packagist.org/packages/jasonmccreary/laravel-additions)[ RSS](/packages/jasonmccreary-laravel-additions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

 [![Build Status](https://github.com/jasonmccreary/laravel-additions/workflows/Build/badge.svg)](https://github.com/jasonmccreary/laravel-additions/actions) [![Latest Stable Version](https://camo.githubusercontent.com/d4e576bb52e64436e9a7920cd8ad1e33136a079b3eb6d68d1281772fb04bbe6c/68747470733a2f2f706f7365722e707567782e6f72672f6a61736f6e6d636372656172792f6c61726176656c2d6164646974696f6e732f762f737461626c652e737667)](https://packagist.org/packages/jasonmccreary/laravel-additions) [![License](https://camo.githubusercontent.com/24b75f29ccd78150ae8f3f93a822ffd01a3bea207424404fa2009a840279ddb3/68747470733a2f2f706f7365722e707567782e6f72672f6a61736f6e6d636372656172792f6c61726176656c2d6164646974696f6e732f6c6963656e73652e737667)](https://github.com/badges/poser/blob/master/LICENSE)

Additions for Laravel
=====================

[](#additions-for-laravel)

This package contains "additions" to Laravel I have used within my Laravel applications over the years. All aim to improve the developer experience and code readability. Many of these additions have been attempted in the Laravel framework, but not yet merged.

Requirements
------------

[](#requirements)

A Laravel application running Laravel 12 or higher. *Not running a supported version of Laravel?* [Upgrade with Shift](https://laravelshift.com).

Installation
------------

[](#installation)

You can install this package by running the following command:

```
composer require -W jasonmccreary/laravel-additions
```

Documentation
-------------

[](#documentation)

A brief description and code sample is provided for each available addition. For a full backstory, you may review their original PR.

---

### `status` helper for responses

[](#status-helper-for-responses)

The `status` helper (attempted in [\#53691](https://github.com/laravel/framework/pull/53691)) is a simple helper to send raw HTTP status code responses. Much like the native `to_route` helper, its aim is to provide a more expressive way to send status codes.

```
// may pass integer HTTP status code directly
return status(404);

// or chain camelCase HTTP status name
return status()->notFound();
```

**Note:** The `status` helper does not allow redirect status codes (3xx). You should use the native `redirect` helper for redirect responses.

---

### Dynamic `findBy*` for models

[](#dynamic-findby-for-models)

This package includes a `FindBy` trait which may be added to your Eloquent models to allow calling dynamic `findBy*` methods for the underlying column names. It is inspired by the [dynamic finders in Rails](https://guides.rubyonrails.org/active_record_querying.html#dynamic-finders), and behaves like the native `find` method with its parameters and return values.

```
// find a single Post model by `title`
Post::findByTitle('Laravel Forever');

// find a set of Post models by `author_id`
Post::findByAuthorId([1, 3, 5]);

// find a single Post model by `author_id` and select only the `title`
Post::findByAuthorId(5, ['title']);
```

To use these dynamic `findBy*` methods, simply add the `FindBy` trait to your model class.

```
