2017-12-17 18:54:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2017-12-17 19:59:10 +01:00
|
|
|
use App\Models\Task;
|
2017-12-17 18:54:54 +01:00
|
|
|
use App\Models\TaskStatus;
|
2017-12-17 21:10:54 +01:00
|
|
|
use App\Models\Project;
|
|
|
|
use App\Models\Client;
|
2017-12-17 18:54:54 +01:00
|
|
|
|
|
|
|
class TaskKanbanController extends BaseController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2017-12-17 21:10:54 +01:00
|
|
|
$tasks = Task::scope()->with(['project', 'client'])->get();
|
|
|
|
$projects = Project::scope()->get();
|
|
|
|
$clients = Client::scope()->get();
|
2017-12-17 18:54:54 +01:00
|
|
|
$stauses = TaskStatus::scope()->get();
|
|
|
|
|
2017-12-17 19:59:10 +01:00
|
|
|
// check initial statuses exist
|
2017-12-17 18:54:54 +01:00
|
|
|
if (! $stauses->count()) {
|
|
|
|
$stauses = [];
|
|
|
|
$defaults = [
|
|
|
|
'backlog',
|
|
|
|
'ready_to_do',
|
|
|
|
'in_progress',
|
|
|
|
'done',
|
|
|
|
];
|
|
|
|
for ($i=0; $i<count($defaults); $i++) {
|
|
|
|
$status = TaskStatus::createNew();
|
|
|
|
$status->name = trans('texts.' . $defaults[$i]);
|
|
|
|
$status->sort_order = $i;
|
|
|
|
$status->save();
|
|
|
|
$stauses[] = $status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'title' => trans('texts.kanban'),
|
|
|
|
'statuses' => $stauses,
|
2017-12-17 19:59:10 +01:00
|
|
|
'tasks' => $tasks,
|
2017-12-17 21:10:54 +01:00
|
|
|
'clients' => $clients,
|
|
|
|
'projects' => $projects,
|
2017-12-17 18:54:54 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
return view('tasks.kanban', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|