【发布时间】:2021-05-17 04:17:34
【问题描述】:
class Property extends Model
{
use HasFactory;
protected $guarded=[];
public function Owner(){
return $this->belongsTo(Owner::class);
}
public function Category(){
return $this->belongsTo(Categpry::class);
}
public function Type(){
return $this->belongsTo(Type::class);
}
public function Uses(){
return $this->belongsTo(Uses::class);
}
public function Other(){
return $this->hasOne(Other::class);
}
public function Street(){
return $this->hasOne(Street::class);
}
public function Part(){
return $this->hasOne(Part::class);
}
public function Pdf(){
return $this->hasOne(Pdf::class);
}
public function Bill(){
return $this->hasOne(Bill::class);
}
public function Numbers(){
return $this->hasOne(Numbers::class);
}
public function Job(){
return $this->hasOne(Job::class);
}
}
public function up()
{
Schema::create('proprietas', function (Blueprint $table) {
$table->id();
$table->string('nomeProprieta')->nullable();
$table->string('int')->nullable();
$table->string('floor')->nullable();
$table->string('street')->nullable();
$table->string('zip')->nullable();
$table->string('city')->nullable();
$table->foreignId('category_id')->constrained();
$table->foreignId('type_id')->constrained();
$table->foreignId('uses_id')->constrained();
$table->timestamps();
});
}
当我尝试通过控制器删除属性时,它给了我错误完整性约束违规:1451 无法删除或更新父行:外键约束失败。 我也尝试过使用 onDelete ('cascade')。 如果有人可以帮助我,我将不胜感激。
【问题讨论】: