当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::withTrashed方法代码示例

本文整理汇总了PHP中app\Project::withTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::withTrashed方法的具体用法?PHP Project::withTrashed怎么用?PHP Project::withTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Project的用法示例。


在下文中一共展示了Project::withTrashed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: down

 /**
  * 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');
     });
 }
开发者ID:genee-projects,项目名称:snail,代码行数:37,代码来源:2016_03_01_115746_change_projects.php

示例2: destroy_project

 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);
         }
     }
 }
开发者ID:hvs-fasya,项目名称:seo_padawan,代码行数:20,代码来源:ProjectController.php

示例3: testDeleteProjectAction

 function testDeleteProjectAction()
 {
     $this->delete('/projects/1')->seeStatusCode(200);
     $this->assertCount(4, Project::withTrashed()->get());
     // definitely deleted
 }
开发者ID:absolux,项目名称:Collabor8-php-api,代码行数:6,代码来源:ProjectsControllerTest.php


注:本文中的app\Project::withTrashed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。