/**
  * Reverse the migrations.
  */
 public function down()
 {
     //恢复步骤
     // 1. 创建 official
     // 2. 数据迁移
     // 3. 删除 signed_status
     //1. 创建 official
     Schema::table('projects', function (Blueprint $table) {
         $table->boolean('official')->default(true);
         //正式客户
     });
     //2. 数据迁移
     foreach (Project::withTrashed() as $project) {
         switch ($project->signed_status) {
             // 正式客户
             case Project::SIGNED_STATUS_OFFICIAL:
                 $project->official = true;
                 $project->save();
                 break;
                 //试用客户
             //试用客户
             case Project::SIGNED_STATUS_PROBATIONARY:
                 $project->official = false;
                 $project->save();
                 break;
             default:
                 break;
         }
     }
     //3. 删除 signed_status
     Schema::table('projects', function (Blueprint $table) {
         $table->dropColumn('signed_status');
     });
 }
 public function destroy_project($project_id)
 {
     if (Gate::denies('manage-project')) {
         abort(403);
     } else {
         try {
             $project = Project::withTrashed()->findOrFail($project_id);
             $client_id = $project->user_id;
             $project_dir = $project->dir;
             $project->forceDelete();
             if (Storage::has($project_dir)) {
                 Storage::deleteDirectory($project_dir);
             }
             return redirect()->action('UserController@show_user', [$client_id])->with('success', "Project successfully destroyed");
         } catch (\Exception $e) {
             $mes = $e->getMessage();
             return Redirect::back()->with('alert', "Failed to destroy project\n" . $mes);
         }
     }
 }
 function testDeleteProjectAction()
 {
     $this->delete('/projects/1')->seeStatusCode(200);
     $this->assertCount(4, Project::withTrashed()->get());
     // definitely deleted
 }