- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个属于多个功能的产品属于多个变体。
产品
public function features()
{
return $this->belongsToMany(Feature::class, 'product_feature', 'product_id', 'feature_id');
}
特征
public function variants()
{
return $this->belongsToMany(Variant::class, 'feature_variant', 'feature_id', 'variant_id');
}
这里
变体 关系取决于
功能 关系。如果
功能 删除了相关的
变体 关系也应该删除。最好的方法是什么?
$product->features()->each(function($feature){
$feature->variants()->each(function($variant){
$variant->sync([]); // $variant()->sync([]) returns Function name must be a string in...
});
});
但得到
BadMethodCallException with message 'Call to undefined method App\Models\ProductFeatureVariant::sync()'
这里的正确方法是什么?
最佳答案
我认为最好的 id 是使用 cascade
它会自动成为你想要的
$table->foreign('feature')->references('id')->on('variant')->onDelete('cascade');
您可以阅读更多关于
cascade
的信息在此
link
关于php - 脱离深层关系(关系关系)的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65896662/
我正在尝试创建一个函数,以便您可以循环遍历一个包含很多对象的大对象,并按值找到特定的方法。我想在使用break语句找到值时停止函数中的循环。这是我的代码。 let fake_window = {
所以,我有以下代码: var name = prompt("What's your name?"); var greeting = "Hello " + name + " :D"; console.
有时,即使是最简单的事情也似乎是不可能的……看看这个,如果您明白我没有看到的东西。 >> LINK 一个 div(绿色),使用类分为两侧 L 和 R。 出于某种原因,类“left-content,ri
许多框架试图从 HTML(自定义标签、JSF 组件系统)中抽象出来,以便更轻松地处理特定的鱼缸。 你们有没有使用过将类似概念应用于 CSS 的东西?可以为您带来一系列跨浏览器魔法的东西,支持类似变量(
我有一个版本历史记录,我正在尝试在其上运行 gradle 构建,并在我的 bash 脚本中运行 while read -r version do git checkout $version
这个问题在这里已经有了答案: Android & RoboGuice - Inject views on Fragment? (1 个回答) 关闭 8 年前。 我有一个 roboactivity,我
我的问题是是否有一个 rails 等同于“脱离” Controller 操作,例如 def new if some_confirmation do_stuff
我厌倦了 此客户端太旧,无法使用工作副本 每当我在使用比石器时代更新的 svn 客户端修复我的工作副本后回到 Eclipse 时。 有没有办法让 Subclipse 使用当前的 Subversion
代码笔示例:http://codepen.io/mattrice/full/peXeqd/ 我想要的是 SVG 完全包含在父级的给定宽度内(本例为 6 列,但可以是任何其他任意宽度的网格元素)。 此示
我正在构建一个带有 TextView、ScrollView 和 LinearLayout 的 Android 应用程序,我想使用 Java 将一个 TextView 和一个 ImageView 添加到
我想在进行一些测试后分析我的 iPhone 应用程序中的数据,这些数据位于 SQLite 数据库中。有什么办法可以将它从 iPhone 复制回我的笔记本电脑吗?我不知道有任何机制允许我进行文件系统样式
我在 div 中有一个(带边框)。这在 Firefox 和 IE 10 上看起来不错(不确定旧版本的 IE)。但是,有时 IE 会激活兼容模式,然后表单(输入框和提交按钮)会脱离 div。是否有一些
内的 anchor 脱离
这是我的html文件 My text content is here...... lINK1lINK2 这是CSS div { width:960px; border:1px so
有人可以指出我研究如何防止用户使用 Ctrl+Z、Ctrl+C? 最佳答案 如果你用 PCNTL 编译了 php (进程控制)并且未运行 Windows,您可以使用 pcntl_signal() .
我是一名优秀的程序员,十分优秀!