Temporary property for Laravel Eloquent model

后端 未结 3 2136
北荒
北荒 2021-02-18 16:13

I have a Laravel Eloquent model User, which has a table with username and email columns. I need to add a property for the model on runtime, something like $user->secure. This pr

3条回答
  •  萌比男神i
    2021-02-18 17:04

    If you intend to make use of that add-on property, then $append will blow your mind.

    http://laraveldaily.com/why-use-appends-with-accessors-in-eloquent/

提交回复
热议问题