mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 08:12:17 +01:00
Added client to time entries
This commit is contained in:
committed by
Constantin Graf
parent
2862033321
commit
ec239f20f2
@@ -155,6 +155,7 @@ class TimeEntryFactory extends Factory
|
||||
return $this->state(function (array $attributes) use ($project) {
|
||||
return [
|
||||
'project_id' => $project?->getKey(),
|
||||
'client_id' => $project?->client_id,
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -164,6 +165,8 @@ class TimeEntryFactory extends Factory
|
||||
return $this->state(function (array $attributes) use ($task) {
|
||||
return [
|
||||
'task_id' => $task?->getKey(),
|
||||
'project_id' => $task?->project?->getKey(),
|
||||
'client_id' => $task?->project?->client?->getKey(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('time_entries', function (Blueprint $table) {
|
||||
$table->foreignUuid('client_id')
|
||||
->nullable()
|
||||
->constrained('clients')
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
});
|
||||
DB::statement('
|
||||
update time_entries
|
||||
set client_id = clients.id
|
||||
from projects
|
||||
join clients on projects.client_id = clients.id
|
||||
where time_entries.project_id = projects.id
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('time_entries', function (Blueprint $table) {
|
||||
$table->dropForeign(['client_id']);
|
||||
$table->dropColumn('client_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -89,6 +89,12 @@ class DatabaseSeeder extends Seeder
|
||||
ProjectMember::factory()->forProject($bigCompanyProject)->forMember($userAcmeAdminMember)->create();
|
||||
ProjectMember::factory()->forProject($bigCompanyProject)->forMember($userWithMultipleOrganizationsAcmeMember)->create();
|
||||
|
||||
TimeEntry::factory()
|
||||
->count(3)
|
||||
->forMember($userAcmeEmployeeMember)
|
||||
->forProject($bigCompanyProject)
|
||||
->create();
|
||||
|
||||
Task::factory()->forOrganization($organizationAcme)->forProject($bigCompanyProject)->create();
|
||||
|
||||
$internalProject = Project::factory()->forOrganization($organizationAcme)->create([
|
||||
|
||||
Reference in New Issue
Block a user