public function editTask(Project $project, Task $task) { $parent = $task->parent; $users = $project->users; $tasks = $project->tasks(true)->get()->except($task->id); $task->loggedTotal(); return view('manage.task-form', ['tasks' => $tasks, 'task' => $task, 'parent' => $parent, 'users' => $users]); }
public function create(Task $task) { if ($task->invoice_id) { return redirect()->route('invoice.edit', $task->invoice_id); } $client = $task->project->client ? $task->project->client->name : ''; $invoice = new Invoice(['name' => ($client ?: 'Invoice') . ' ' . date('Y-m-d'), 'issued_at' => date('Y-m-d'), 'invoiceno' => $task->project->company->invoiceno + 1, 'client_name' => $client ?: '', 'company_name' => $task->project->company->name, 'items' => [['name' => $task->name, 'description' => $task->description, 'rate' => 10, 'hours' => round($task->loggedTotal()), 'total' => 0]], 'company_id' => $task->project->company_id, 'client_id' => $task->project->client_id, 'project_id' => $task->project_id]); $task->project->company->update(['invoiceno' => $task->project->company->invoiceno + 1]); $invoice->save(); $task->invoice_id = $invoice->id; $task->save(); return view('invoice.editor', ['invoice' => $invoice]); }