[Laravel] 5.6.9がリリースされました

Laravelのバージョン5.6.85.6.9がリリースされました。更新された機能について確認していきます。

Changed (5.6.9)

セッションの再発行時 (Session::regenerate) にトークン情報も再設定されるようになりました。

また、潜在的なXSSに対する修正により、Bootstrapのscaffoldingが変更されました。

JS Frameworks, Server Side Rendering, and XSS – Taylor Otwell – Medium

<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
    {{ Auth::user()->name }} <span class="caret"></span>
</a>

v-pre属性を付与することにより既存のコードを修正できます。

Regenerate token when regenerating the session (@20e8419)

Fixed (5.6.9)

Fixed an issue with resources when loading a single merge value with an associative array (#23414)


Release v5.6.9 · laravel/framework · GitHub

Added (5.6.8)

MySQLのsounds likeが利用可能になりました。

$builder->select('*')->from('users')->where('name', 'sounds like', 'John Doe');

Added support for MySQL’s sounds-like operator (#23351)


リクエスト数超過時の例外にIlluminate\Http\Exceptions\ThrottleRequestsExceptionが投げられるようになりました。

Added ThrottleRequestsException exception (#23358)


Bladeエンジンに@dumpディレクティブが追加されました。

Added @dump Blade directive (#23364)


Collection::whereInstanceOfMethod()メソッドが追加されました。

メッソド名の通り、指定のクラスをコレクションからフィルタリングできます。

$c = new Collection([new stdClass, new stdClass, new Collection, new stdClass]);
$this->assertCount(3, $c->whereInstanceOf(stdClass::class));

Added Collection::whereInstanceOfMethod() (@78b5b92)


Dispatchable::dispatchNow()メソッドが追加されました。

Illuminate\Contracts\Bus\Dispatcher\Dispatchableトレイトを利用する場合にも同期的にJOB実行が可能になりました。

Added Dispatchable::dispatchNow() (#23399)

Changed (5.6.8)

DatabaseNotificationを使用する際に発行される通知データを変更可能になりました。

\Illuminate\Notifications\Channels\DatabaseChannel::buildPayload()メソッドをOverwriteすることで、Model毎の通知データをカスタマイズできます。

/**
 * Build an array payload for the DatabaseNotification Model.
 *
 * @param  mixed  $notifiable
 * @param  \Illuminate\Notifications\Notification  $notification
 * @return array
 */
protected function buildPayload($notifiable, Notification $notification)
{
    return [
        'id' => $notification->id,
        'type' => get_class($notification),
        'data' => $this->getData($notifiable, $notification),
        'read_at' => null,
    ];
}

Allow extension of DatabaseNotification model attributes (#23337)


認証系のscaffoldingがi18nに対応しました。

make:authコマンドで生成されるBladeファイルの全てが修正されました。

下記はresources/views/auth/login.blae.phpのstubファイルです。

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Login') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('login') }}">
                        @csrf

                        <div class="form-group row">
                            <label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>

                                @if ($errors->has('email'))
                                    <span class="invalid-feedback">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="invalid-feedback">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-6 offset-md-4">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> {{ __('Remember Me') }}
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-8 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Login') }}
                                </button>

                                <a class="btn btn-link" href="{{ route('password.request') }}">
                                    {{ __('Forgot Your Password?') }}
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Made auth scaffolding translatable (#23342)


Eloquent ModelのgetForeignKey()(リレーションを作成する際に外部キーを取得するメソッド)の処理が変更されました。

Str::snake(class_basename($this)).'_'.$this->primaryKeyからStr::snake(class_basename($this)).'_'.$this->getKeyName()変更されました。

これによってgetKeyName()をOverwrite可能になり、継承先のモデルからでも外部キーの変更が可能になりました。

Use getKeyName() in getForeignKey() (#23362)


FileSystemにてファイルやディレクトリを複数取得する際のソート順が名前順に変更されました。

Sort FileSystem files and directories by name (#23387)


Validatorのvalidate()メソッドが検証済みの値を返却するように変更されました。

Return validated data from Validator::validate() (#23397, @3657d66)

Fixed

serveコマンドが修正されました

Fixed serve command escaping (#23348)


Query BuilderのwithCount()メソッドの実装が移動されました。

Fixed an issue with multiple select statements in combination with withCount() (#23357)


Conditional loadの方法を修正しました。

Fixed conditional loading issues (#23369)


Model Factoryで配列を指定した場合の挙動が修正されました。

Prevent considering arrays as callable while building model factories (#23372)


Composerでtighenco/collectがコンフリクトしていた問題を修正しました。

Move tightenco/collect to Composer’s conflict (#23379)


View内でループの引数にTraversableオブジェクトを渡した際の挙動が修正されました。

Set up loop variable correctly on all Traversable objects (#23388, @49770ec)


Pivot Modelで値をフィルタリングする処理が修正されました。

Removed attribute filling from pivot model (#23401


Release v5.6.8 · laravel/framework · GitHub

© Xzxzyzyz