dpno17028 2017-07-23 04:06
浏览 299
已采纳

暂时禁用Laravel附加

Is it possible to temporarily disable the appends functionality in Laravel 5.4 during testing?

protected $appends = [
        'full_name',
    ];

I want to ignore that ^.

I've made a model factory but when I'm testing I don't want to have these append items on my model.

  • 写回答

3条回答 默认 最新

  • doulu7921 2017-07-23 07:56
    关注

    I have had experience with this too. I've found a good solution here.

    But, if you like a one-liner solution, you can also use the ff methods of Eloquent's Model class:

    • setHidden(array $hidden)

    • makeHidden(array|string $attributes)

    You can check these here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?