Added ability to archive projects and clients, fixes ST-37

This commit is contained in:
Constantin Graf
2024-06-24 13:36:30 +02:00
committed by Gregor Vostrak
parent f21a2d4bdd
commit a69d1cb4c4
17 changed files with 524 additions and 10 deletions

View File

@@ -13,11 +13,11 @@ use App\Http\Resources\V1\Project\ProjectResource;
use App\Models\Organization;
use App\Models\Project;
use App\Models\ProjectMember;
use App\Models\User;
use App\Service\BillableRateService;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class ProjectController extends Controller
@@ -51,6 +51,12 @@ class ProjectController extends Controller
if (! $canViewAllProjects) {
$projectsQuery->visibleByEmployee($user);
}
$filterArchived = $request->getFilterArchived();
if ($filterArchived === 'true') {
$projectsQuery->whereNotNull('archived_at');
} elseif ($filterArchived === 'false') {
$projectsQuery->whereNull('archived_at');
}
$projects = $projectsQuery->paginate(config('app.pagination_per_page_default'));
@@ -108,6 +114,9 @@ class ProjectController extends Controller
$project->name = $request->input('name');
$project->color = $request->input('color');
$project->is_billable = (bool) $request->input('is_billable');
if ($request->has('is_archived')) {
$project->archived_at = $request->getIsArchived() ? Carbon::now() : null;
}
$project->billable_rate = $request->getBillableRate();
$project->client_id = $request->input('client_id');
$project->save();