I have an Laravel 4
app with polls and different options or choices to vote. The problem is that when I destroy a poll, the options are not deleted from the database.
These are my main migrations:
Polls:
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();
});
}
Options:
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();
});
}
And this is the code that deletes:
Poll::destroy($id);
I am using sqlite
as my DB enging right now.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire