0
我有我的用户表(名称,电子邮件,密码等),用户可以上传图片,文件或视频。删除文件/上传时删除用户
他们的照片都存储在特定的路径(例如/myproject/app/public/uploads/01/picture.jpg
)
我想,如果由用户上传的文件可以在用户的行被删除被删除。
最大的问题是,我想删除的数据,该用户上传,当我做php artisan migrate:refresh --seed
我想这对迁移文件2014_..._create_users_table.php
:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use File;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
// Deleting ALL the data that the users have uploaded
$dir = public_path(). "/uploads/";
File::deleteDirectory($dir, true);
}
}
但我有以下错误当我尝试执行时php artisan migrate:refresh --seed
[ErrorException]
The use statement with non-compound name 'File' has no effect
谢谢你的帮忙!
谢谢!有效 ! ^^ – Didi