mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Projects and Tasks factories. (#3234)
* Working on projects and tasks * Fixes for company transformer * projects and tasks factories
This commit is contained in:
parent
1e7b9007d1
commit
8c7f4ab09f
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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),
|
||||
|
12
database/factories/ProjectFactory.php
Normal file
12
database/factories/ProjectFactory.php
Normal 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),
|
||||
];
|
||||
});
|
11
database/factories/TaskFactory.php
Normal file
11
database/factories/TaskFactory.php
Normal 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),
|
||||
];
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user