Php Laravel资源附加本地修改的属性
我希望返回模型的Php Laravel资源附加本地修改的属性,php,laravel,Php,Laravel,我希望返回模型的资源,同时将本地更改附加到模型中已存在的某些属性(以不更改数据库值的方式)。要实现这一点,正确的调用方法是什么(因为append函数不正确) 这不会修改数据库: $tempCurrency = $this->findCurrecy($model->currency); $model->currency = $tempCurrency; 只要您以后不在$model上调用save(),数据库就不会受到影响。好吧,但实际上有些变量有时可能会有所不同:我的意思是想象货
资源
,同时将本地更改附加到模型中已存在的某些属性(以不更改数据库值的方式)。要实现这一点,正确的调用方法是什么(因为append
函数不正确)
这不会修改数据库:
$tempCurrency = $this->findCurrecy($model->currency);
$model->currency = $tempCurrency;
只要您以后不在
$model
上调用save()
,数据库就不会受到影响。好吧,但实际上有些变量有时可能会有所不同:我的意思是想象货币和名称一次,货币、名称和标题另一次。所以它是一个字段数组。
$tempCurrency = $this->findCurrecy($model->currency);
$model->currency = $tempCurrency;