本文整理汇总了PHP中app\Task::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::onlyTrashed方法的具体用法?PHP Task::onlyTrashed怎么用?PHP Task::onlyTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::onlyTrashed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request, $id = Null)
{
$user = Auth::user();
// If the user is not an Admin, only show his own tasks
if ($user->is_admin) {
if ($request->is('*/user/*')) {
$tasks = Task::where('user_id', $id)->get();
} elseif ($request->is('*/category/*')) {
$tasks = Task::where('category_id', $id)->get();
} else {
$tasks = Task::get();
}
// also retrieve the trashed tasks
$trashed = Task::onlyTrashed()->get();
} else {
$tasks = Task::where('user_id', $user->id)->get();
// also retrieve the trashed tasks
$trashed = Task::onlyTrashed()->get();
}
$heading = 'My Tasks';
//
return view('tasks', array('tasks' => $tasks, 'heading' => $heading, 'trashed' => $trashed));
}
示例2: deleted
public function deleted()
{
return Task::onlyTrashed()->get();
}
示例3: getTrashed
/**
* Gets all trashed tasks
*
* @return \Illuminate\Http\Response
*/
public function getTrashed()
{
return response()->json(Task::onlyTrashed()->with('user', 'category')->get());
}
示例4: trash
public function trash()
{
$tasks = Task::onlyTrashed()->get();
return view('tasks.trash', compact('tasks'));
}