class CreateCommentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->text('comment');
$table->boolean('approved');
$table->integer('post_id')->unsigned();
$table->timestamps();
});
Schema::table('comments', function (Blueprint $table) {
$table->foreign('post_id')->references('id')->on('posts');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropForeign(['post_id']);
Schema::dropIfExists('comments');
}
}
This is what my migration class looks like, i have been trying to delete the table from the database but it throws me an error.
Error
Call to undefined method Illuminate\Database\Schema\MySqlBuilder::dropForeign()
I have gone through the documentation but it doesnot seem to be of much help.
could anyone please point out my mistake and what would be the solution ?
Just so you know , i am new to laravel.Go easy on me.Thanks!.