1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Projects and Tasks factories. (#3234)

* Working on projects and tasks

* Fixes for company transformer

* projects and tasks factories
This commit is contained in:
David Bomba 2020-01-21 20:22:10 +11:00 committed by GitHub
parent 1e7b9007d1
commit 8c7f4ab09f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 2 deletions

View File

@ -145,6 +145,13 @@ class CreateTestData extends Command
$this->info('creating vendor for client #'.$client->id);
$this->createVendor($client);
$this->info('creating task for client #'.$client->id);
$this->createTask($client);
$this->info('creating project for client #'.$client->id);
$this->createProject($client);
}
}
@ -221,6 +228,11 @@ class CreateTestData extends Command
$this->info('creating vendor for client #'.$client->id);
$this->createVendor($client);
$this->info('creating task for client #'.$client->id);
$this->createTask($client);
$this->info('creating project for client #'.$client->id);
$this->createProject($client);
}
}
@ -297,6 +309,11 @@ class CreateTestData extends Command
$this->info('creating vendor for client #'.$client->id);
$this->createVendor($client);
$this->info('creating task for client #'.$client->id);
$this->createTask($client);
$this->info('creating project for client #'.$client->id);
$this->createProject($client);
}
}
@ -364,11 +381,19 @@ class CreateTestData extends Command
private function createTask($client)
{
$vendor = factory(\App\Models\Task::class)->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id
]);
}
private function createProject($client)
{
$vendor = factory(\App\Models\Project::class)->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id
]);
}
private function createInvoice($client)

View File

@ -13,10 +13,12 @@ namespace App\Models;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Task extends BaseModel
{
use MakesHash;
use SoftDeletes;
protected $fillable = [
'client_id',

View File

@ -35,7 +35,7 @@ class TaskTransformer extends EntityTransformer
return [
'id' => (string) $this->encodePrimaryKey($task->id),
'description' => $task->description ?: '',
'duration' => $task->getDuration() ?: 0,
// 'duration' => $task->getDuration() ?: 0,
'updated_at' => (int)$task->updated_at,
'archived_at' => (int)$task->deleted_at,
'invoice_id' => $this->encodePrimaryKey($task->invoice_id),

View File

@ -0,0 +1,12 @@
<?php
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Project::class, function (Faker $faker) {
return [
'name' => $faker->name(),
'description' => $faker->text(50),
];
});

View File

@ -0,0 +1,11 @@
<?php
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Task::class, function (Faker $faker) {
return [
'description' => $faker->text(50),
];
});