本文整理汇总了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');
});
}
示例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);
}
}
}
示例3: testDeleteProjectAction
function testDeleteProjectAction()
{
$this->delete('/projects/1')->seeStatusCode(200);
$this->assertCount(4, Project::withTrashed()->get());
// definitely deleted
}