本文整理汇总了PHP中app\Task::withTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::withTrashed方法的具体用法?PHP Task::withTrashed怎么用?PHP Task::withTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::withTrashed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
public function restore(Request $request)
{
$data = $request->all();
$task = Task::withTrashed()->find($data->id)->restore();
return $task;
}
示例2: forceDelete
/**
* Permanently delete a resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function forceDelete($id)
{
// find a single resource by ID
$output = Task::withTrashed()->where('id', $id);
if ($output) {
// model uses soft deletes...
Task::withTrashed()->where('id', $id)->forceDelete();
$status = 'Task with id "' . $id . '" has been permanently deleted.';
return \Redirect::route('tasks.index')->with(['status' => $status]);
}
//
$message = 'Task with ID "' . $id . '" not found';
return \Redirect::route('tasks.index')->withErrors(['status' => $message]);
}
示例3: permDelete
/**
* Permanently delete a task
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function permDelete($id)
{
$arrRet = array('success' => true);
Task::withTrashed()->find($id)->forceDelete();
return response()->json($arrRet);
}
示例4: testDestroyTask
/**
* Test destroyTask.
*/
public function testDestroyTask()
{
$controller = new TaskController();
$task = factory(\App\Task::class)->create($this->taskData);
$this->expectsEvents('App\\Events\\TaskDeletedEvent');
$this->response = $controller->destroyTask($task->id);
$this->assertEquals(200, $this->response->status());
// Check that the task cannot be found.
$deletedTask = Task::find($task->id);
$this->assertNull($deletedTask);
// Check that task was soft-deleted.
$deletedTask = Task::withTrashed()->find($task->id);
$this->assertNotNull($deletedTask);
}
示例5: testDestroyTask
/**
* Test destroyTask.
*/
public function testDestroyTask()
{
$task = factory(\App\Task::class)->create($this->taskData);
$this->delete('/api/v0_01/tasks/' . $task->id, array(), static::$headers);
$this->assertEquals(200, $this->response->status());
// Check that the task cannot be found.
$deletedTask = Task::find($task->id);
$this->assertNull($deletedTask);
// Check that task was soft-deleted.
$deletedTask = Task::withTrashed()->find($task->id);
$this->assertNotNull($deletedTask);
// $this->notSeeInDatabase('tasks', ['id' => $task->id]);
}
示例6: function
Route::get('/home', 'HomeController@home');
/**
* Show Task Dashboard
*/
Route::get('/tasks', 'TaskController@index');
/**
* Add New Task
*/
Route::post('/task', 'TaskController@store');
/**
* Delete Task
*/
Route::delete('/task/{task}', 'TaskController@delete');
// EXPLICIT BINDING per recuperare i models soft deleted
Route::bind('deletedTask', function ($task) {
return Task::withTrashed()->findOrFail($task);
});
/**
* HARD Delete Task
*/
Route::delete('/task/{deletedTask}/hard', 'TaskController@hardDelete')->name('hard-delete');
/**
* Restore Task
*/
Route::post('/task/{deletedTask}/restore', 'TaskController@restore')->name('restore');
/**
* Generate PDF Task
*/
Route::get('/task/pdf/{task}', 'TaskController@taskToPDF');
});
//Route::get('/api/test', function() {