我在我的数据库中存储了一些字符串,我希望能够使用它们获取模型属性。
基本上,我可以打电话给这样的用户预订
$user->bookings->date
在我的控制器中,它可以工作,我正在像这样在我的数据库中存储一个字符串
'user->bookings->date'
如何使用数据库中的这个字符串来获取属性?我希望能够做类似的事情
$user = User::findOrFail(1);
$string = 'user->bookings->date'; //This is fetched from the db normally
$booking_date = ${$string}; //Instead of writing $user->bookings->date
这可能吗?
慕码人2483693