【发布时间】:2023-03-22 05:03:01
【问题描述】:
我正在使用多个控制器,在这些控制器中我以驼峰格式接收输入,我需要将这些属性分配给模型:
$scopeCommercial = new ScopeCommercial();
$scopeCommercial->lifetime_sales = $request->lifetimeSales;
$scopeCommercial->lifetime_volumes = $request->lifetimeVolumes;
问题是我的模型有大约 30 个属性,我不想一一写出来。 我知道我可以使用request 来获取所有属性:
$input = $request->all();
有没有办法将驼峰格式的属性与数据库标准等效转换?类似于 camel 方法的逆:
$converted = Str::camel('foo_bar');
【问题讨论】: