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


PHP Task::withTrashed方法代码示例

本文整理汇总了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;
 }
开发者ID:sezertunca,项目名称:laravel-tasks,代码行数:6,代码来源:EloquentTaskRepository.php

示例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]);
 }
开发者ID:matthiku,项目名称:LaravelWithSocialite,代码行数:20,代码来源:TaskController.php

示例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);
 }
开发者ID:tanko2224,项目名称:envoy-todo-list,代码行数:12,代码来源:TaskController.php

示例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);
 }
开发者ID:juboba,项目名称:Luminosity,代码行数:17,代码来源:TaskControllerMethodsTest.php

示例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]);
 }
开发者ID:juboba,项目名称:Luminosity,代码行数:16,代码来源:TaskControllerTest.php

示例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() {
开发者ID:grisoni77,项目名称:laravel_tutorial,代码行数:31,代码来源:routes.php


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