task_status_repo = $task_status_repo; } /** * index * * @param TaskStatusFilters $filters * @return Response| \Illuminate\Http\JsonResponse */ public function index(TaskStatusFilters $filters) { $task_status = TaskStatus::filter($filters); return $this->listResponse($task_status); } /** * create * * @param CreateTaskStatusRequest $request * @return Response| \Illuminate\Http\JsonResponse */ public function create(CreateTaskStatusRequest $request) { /** @var \App\Models\User $user */ $user = auth()->user(); $task_status = TaskStatusFactory::create($user->company()->id, auth()->user()->id); return $this->itemResponse($task_status); } /** * Store a newly created resource in storage. * * @param StoreTaskStatusRequest $request The request * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreTaskStatusRequest $request) { /** @var \App\Models\User $user */ $user = auth()->user(); $task_status = TaskStatusFactory::create($user->company()->id, auth()->user()->id); $task_status->fill($request->all()); $task_status->save(); return $this->itemResponse($task_status->fresh()); } /** * @param ShowTaskStatusRequest $request * @param TaskStatus $task_status * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function show(ShowTaskStatusRequest $request, TaskStatus $task_status) { return $this->itemResponse($task_status); } /** * @param EditTaskStatusRequest $request * @param TaskStatus $payment * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function edit(EditTaskStatusRequest $request, TaskStatus $payment) { return $this->itemResponse($payment); } /** * Update the specified resource in storage. * * @param UpdateTaskStatusRequest $request The request * @param TaskStatus $task_status The payment term * @return Response| \Illuminate\Http\JsonResponse */ public function update(UpdateTaskStatusRequest $request, TaskStatus $task_status) { $task_status->fill($request->all()); $reorder = $task_status->isDirty('status_order'); $task_status->save(); if ($reorder) { $this->task_status_repo->reorder($task_status); } return $this->itemResponse($task_status->fresh()); } /** * Remove the specified resource from storage. * * @param DestroyTaskStatusRequest $request * @param TaskStatus $task_status * @return Response| \Illuminate\Http\JsonResponse * * @throws \Exception */ public function destroy(DestroyTaskStatusRequest $request, TaskStatus $task_status) { $task_status = $this->task_status_repo->delete($task_status); return $this->itemResponse($task_status); } /** * Perform bulk actions on the list view. * @param ActionTaskStatusRequest $request * @return Response| \Illuminate\Http\JsonResponse */ public function bulk(ActionTaskStatusRequest $request) { $action = $request->input('action'); $ids = $request->input('ids'); TaskStatus::withTrashed() ->company() ->whereIn('id', $this->transformKeys($ids)) ->cursor() ->each(function ($task_status, $key) use ($action) { $this->task_status_repo->{$action}($task_status); }); return $this->listResponse(TaskStatus::withTrashed()->whereIn('id', $this->transformKeys($ids))); } }