mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Working on projects and tasks (#3232)
This commit is contained in:
parent
63de0d86ca
commit
a1ae991684
@ -361,6 +361,16 @@ class CreateTestData extends Command
|
||||
|
||||
}
|
||||
|
||||
private function createTask($client)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function createProject($client)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function createInvoice($client)
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
|
@ -88,6 +88,8 @@ class BaseController extends Controller
|
||||
'company.quotes',
|
||||
'company.vendors',
|
||||
'company.expenses',
|
||||
'company.tasks',
|
||||
'company.projects',
|
||||
];
|
||||
} else {
|
||||
$include = [
|
||||
|
@ -114,6 +114,22 @@ class Company extends BaseModel
|
||||
return $this->hasMany(Client::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function tasks()
|
||||
{
|
||||
return $this->hasMany(Task::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function projects()
|
||||
{
|
||||
return $this->hasMany(Project::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -31,7 +31,11 @@ class Project extends BaseModel
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -28,6 +28,10 @@ class Task extends BaseModel
|
||||
'time_log',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function documents()
|
||||
{
|
||||
|
@ -21,7 +21,9 @@ use App\Models\Expense;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\Quote;
|
||||
use App\Models\Task;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -61,6 +63,8 @@ class CompanyTransformer extends EntityTransformer
|
||||
'company_gateways',
|
||||
'activities',
|
||||
'quotes',
|
||||
'projects',
|
||||
'tasks',
|
||||
];
|
||||
|
||||
|
||||
@ -139,6 +143,20 @@ class CompanyTransformer extends EntityTransformer
|
||||
return $this->includeCollection($company->clients, $transformer, Client::class);
|
||||
}
|
||||
|
||||
public function includeProjects(Company $company)
|
||||
{
|
||||
$transformer = new ProjectTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($company->projects, $transformer, Project::class);
|
||||
}
|
||||
|
||||
public function includeClients(Company $company)
|
||||
{
|
||||
$transformer = new TaskTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($company->tasks, $transformer, Task::class);
|
||||
}
|
||||
|
||||
public function includeExpenses(Company $company)
|
||||
{
|
||||
$transformer = new ExpenseTransformer($this->serializer);
|
||||
|
54
app/Transformers/ProjectTransformer.php
Normal file
54
app/Transformers/ProjectTransformer.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
* class ProjectTransformer
|
||||
*/
|
||||
class ProjectTransformer extends EntityTransformer
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected $defaultIncludes = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
];
|
||||
|
||||
public function transform(Project $project)
|
||||
{
|
||||
return [
|
||||
'id' => (string) $this->encodePrimaryKey($project->id),
|
||||
'name' => $project->name ?: '',
|
||||
'client_id' => (string) $this->encodePrimaryKey($project->client_id),
|
||||
'updated_at' => (int)$project->updated_at,
|
||||
'archived_at' => (int)$project->deleted_at,
|
||||
'is_deleted' => (bool) $project->is_deleted,
|
||||
'task_rate' => (float) $project->task_rate,
|
||||
'due_date' => $project->due_date ?: '',
|
||||
'private_notes' => $project->private_notes ?: '',
|
||||
'budgeted_hours' => (float) $project->budgeted_hours,
|
||||
'custom_value1' => $project->custom_value1 ?: '',
|
||||
'custom_value2' => $project->custom_value2 ?: '',
|
||||
'custom_value3' => $project->custom_value3 ?: '',
|
||||
'custom_value4' => $project->custom_value4 ?: '',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
55
app/Transformers/TaskTransformer.php
Normal file
55
app/Transformers/TaskTransformer.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Task;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
/**
|
||||
* class TaskTransformer
|
||||
*/
|
||||
class TaskTransformer extends EntityTransformer
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected $defaultIncludes = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
];
|
||||
|
||||
public function transform(Task $task)
|
||||
{
|
||||
return [
|
||||
'id' => (string) $this->encodePrimaryKey($task->id),
|
||||
'description' => $task->description ?: '',
|
||||
'duration' => $task->getDuration() ?: 0,
|
||||
'updated_at' => (int)$task->updated_at,
|
||||
'archived_at' => (int)$task->deleted_at,
|
||||
'invoice_id' => $this->encodePrimaryKey($task->invoice_id),
|
||||
'client_id' => $this->encodePrimaryKey($task->client_id),
|
||||
'project_id' => $this->encodePrimaryKey($task->project_id),
|
||||
'is_deleted' => (bool) $task->is_deleted,
|
||||
'time_log' => $task->time_log ?: '',
|
||||
'is_running' => (bool) $task->is_running,
|
||||
'custom_value1' => $task->custom_value1 ?: '',
|
||||
'custom_value2' => $task->custom_value2 ?: '',
|
||||
'custom_value3' => $task->custom_value3 ?: '',
|
||||
'custom_value4' => $task->custom_value4 ?: '',
|
||||
'task_status_id' => $this->encodePrimaryKey($task->task_status_id),
|
||||
'task_status_sort_order' => (int) $task->task_status_sort_order,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user