PHPackages                             kanagama/laravel-add-formrequest-accessor - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kanagama/laravel-add-formrequest-accessor

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kanagama/laravel-add-formrequest-accessor
=========================================

Laravel の FormRequest に accessor 機能を付与する

v2.0.1(2y ago)25.5k↑435.1%[7 PRs](https://github.com/kanagama/laravel-add-formrequest-accessor/pulls)MITPHPPHP ^8.0 | ^8.1 | ^8.2

Since Dec 17Pushed today2 watchersCompare

[ Source](https://github.com/kanagama/laravel-add-formrequest-accessor)[ Packagist](https://packagist.org/packages/kanagama/laravel-add-formrequest-accessor)[ RSS](/packages/kanagama-laravel-add-formrequest-accessor/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (32)Used By (0)

laravel-add-formrequest-accessor
================================

[](#laravel-add-formrequest-accessor)

laravel の FormRequest に accessor 機能を付与します。

Qiita に詳しい説明書いてます
-----------------

[](#qiita-に詳しい説明書いてます)

インストール
------

[](#インストール)

```
$ composer require kanagama/laravel-add-formrequest-accessor:2.*

```

使い方
---

[](#使い方)

引数ありませんが、model のアクセサと似せました。 下記コードを参照して下さい

### Request

[](#request)

```
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Kanagama\FormRequestAccessor\FormRequestAccessor;

/**
 * @property-read string $full_name
 */
class BookingRequest extends FormRequest
{
    use FormRequestAccessor;

    /**
     * フルネームを取得
     *
     * @return string
     *
     * @author k.nagama
     */
    public function getFullNameAttribute(): string
    {
        return $this->input('last_name') .' '. $this->input('first_name');
    }
}
```

### controller など

[](#controller-など)

```
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Requests\BookingRequest;

class BookingController extends Controller
{
    /**
     * @param  BookingRequest  $request
     *
     * @author k.nagama
     */
    public function reserve(BookingRequest $request)
    {
        dd($request->full_name);
    }
```

### $guarded

[](#guarded)

$guarded で指定したプロパティは、all() ファンクションで出力されません。

```
protected $guarded = [
    'first_name',
];
```

### $fill

[](#fill)

$fill で指定したプロパティのみ all() ファンクションで出力されます。 $guarded と一緒に記述されていた場合、$fill が優先されます。

```
protected $fill = [
    'first_name',
];
```

### null\_disabled

[](#null_disabled)

$null\_disabled で指定したアクセサの戻り値が null の場合、出力されません

### empty\_disabled

[](#empty_disabled)

$empty\_disabled で指定したアクセサの戻り値が空（empty()チェック）の場合、出力されません

casts
-----

[](#casts)

指定したプロパティの型を変換します。 model の $casts と同様の挙動をします。

```
protected $casts = [
    'id'        => 'int',
    'from_date' => 'string',
    'view_flg'  => 'bool',
];
```

test
----

[](#test)

php vendor/bin/phpunit

analysis
--------

[](#analysis)

vendor/bin/phpstan analyse -l 3 src/

metrics
-------

[](#metrics)

php ./vendor/bin/phpmetrics --report-html=phpmetrics src/

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance65

Regular maintenance activity

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~37 days

Total

23

Last Release

943d ago

Major Versions

v1.9.0.x-dev → v2.0.02023-08-07

PHP version history (4 changes)v1.0.0PHP ^7.3 || ^8.0

v1.1.0PHP ^7.4 || ^8.0

v1.9.0PHP ^7.4 | ^8.0 | ^8.1 | ^8.2

v2.0.0PHP ^8.0 | ^8.1 | ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/be317eed08600136c2e3350d92d57160b0a683957131591389d9bd42fa3b543e?d=identicon)[k-nagama](/maintainers/k-nagama)

---

Top Contributors

[![kanagama](https://avatars.githubusercontent.com/u/80406579?v=4)](https://github.com/kanagama "kanagama (63 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (3 commits)")[![kazumacchi](https://avatars.githubusercontent.com/u/46663366?v=4)](https://github.com/kazumacchi "kazumacchi (2 commits)")

---

Tags

extensionlaravelphplaravelaccessorformrequest

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kanagama-laravel-add-formrequest-accessor/health.svg)

```
[![Health](https://phpackages.com/badges/kanagama-laravel-add-formrequest-accessor/health.svg)](https://phpackages.com/packages/kanagama-laravel-add-formrequest-accessor)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
