我有一个Laravel 4
个应用程序,包含民意调查和不同的选项或选择。问题是,当我销毁一个民意调查时,选项不会从数据库中删除。
这些是我的主要迁移:
投票:
private $table = 'polls';
public function down() {
Schema::dropIfExists($this->table);
}
public function up() {
Schema::create($this->table, function(Blueprint $table) {
$table->increments('id');
$table->string( 'owner' )->unsigned();
$table->foreign('owner' )->references('id')->on('users')->onDelete('cascade');
$table->string( 'topic' );
$table->boolean('multichoice')->default(false);
$table->boolean('signed' )->default(false); // Marks if the poll can be voted only by authenticated users
$table->timestamps();
});
}
选项:
private $table = 'options';
public function down() {
Schema::dropIfExists($this->table);
}
public function up() {
Schema::create($this->table, function(Blueprint $table) {
$table->increments('id');
$table->integer( 'poll_id')->unsigned();
$table->foreign( 'poll_id')->references('id')->on('polls')->onDelete('cascade');
$table->string( 'name' );
$table->integer( 'votes' )->default(0);
$table->timestamps();
});
}
这是删除的代码:
Poll::destroy($id);
我现在正在使用sqlite
作为我的数据库。
我做错了什么?