I got two database table like this
Schema::create('folders', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->foreignId('parent_id')->nullable()->constrained('folders')->cascadeOnDelete();
$table->string('path')->nullable();
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->timestamps();
});
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('path')->nullable();
$table->string('size');
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->string('image_url')->nullable();
$table->foreignId('folder_id')->nullable()->constrained('folders')->cascadeOnDelete();
$table->timestamps();
});
I try to use Model Event but I not really understand it
Now when I delete a folder and, in that folder, have a file so I want to remove a file when a delete is removed. File is I upload from PC but folder just create by link does not create a physical folder in PC.
New contributor
Ductn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.