05_2_softdeleteしたユーザ情報を取得 - hpscript/laravel GitHub Wiki

controller

User::withTrashed()->get();

belongsToの場合

public function user(){
        return $this->belongsTo('App\User')->withTrashed();
    }

このようにすれば、わざわざViewで条件処理を加えなくて済む。

{{ $hoge->user ? $hoge->user->name : 'ユーザ削除済' }}

User::query()の場合

-> 後ろにつける

$query = User::query()->withTrashed();

User::withTrashed()->query();とするとエラーになるので注意が必要