Hello, whenever i tried deleting a record, the parent get deleted, but the children don't. Please help me out. Here are my migrations:
// FOR ACCOUNTS which is the same as Users
public function up()
{
Schema::create('accounts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('fname', 200);
$table->string('lname', 200);
$table->string('gender', 10)->nullable();
$table->string('dob', 100)->nullable()
$table->timestamps();
});
//FOR LOANS
public function up()
{
Schema::create('loans', function (Blueprint $table) {
$table->id();
$table->mediumText('project_location');
$table->string('business_VAT', 100);
$table->integer('account_id')->unsigned();
$table->timestamps();
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
});
}
// For purpose loans
public function up()
{
Schema::create('purpose_loans', function (Blueprint $table) {
$table->id();
$table->mediumText('loan_purpose');
$table->string('loan_type', 200);
$table->bigInteger('loan_id')->unsigned();
$table->timestamps();
$table->foreign('loan_id')->references('id')->on('loans')->onDelete('cascade');
});
}
// For Status Loan
public function up()
{
Schema::create('status_loans', function (Blueprint $table)
{
$table->id();
$table->string('status', 100)->nullable()->default('processing');
$table->bigInteger('amount_recommended')->nullable()->default(0);
$table->bigInteger('loan_id')->unsigned();
$table->timestamps();
$table->foreign('loan_id')->references('id')->on('loans')->onDelete('cascade');
});
}
Top comments (1)
Thank you very much... i have solved it already... its just the different between these two table types MyISAM and InnoDB