Browse Source

Merge branch 'dev' into requirement-import-and-export-link-plan

moell 7 months ago
parent
commit
7590dc972f

+ 4 - 0
app/Providers/AppServiceProvider.php

@@ -2,6 +2,7 @@
 
 namespace App\Providers;
 
+use App\Tools\ApiPaginator;
 use Illuminate\Support\ServiceProvider;
 
 class AppServiceProvider extends ServiceProvider
@@ -20,5 +21,8 @@ class AppServiceProvider extends ServiceProvider
     public function boot(): void
     {
         //
+        $this->app->bind('Illuminate\Pagination\LengthAwarePaginator', function ($app, $options) {
+            return new ApiPaginator($options['items'], $options['total'], $options['perPage'], $options['currentPage'], $options['options']);
+        });
     }
 }

+ 2 - 0
app/Services/Project/ProjectGanttService.php

@@ -51,6 +51,7 @@ class ProjectGanttService
             'text' => $name,
             'parent' => 0,
             'start_date' => null,
+            'end_date' => null,
             'duration' => null,
             'progress' => 0,
             'assign_to' => null,
@@ -80,6 +81,7 @@ class ProjectGanttService
             'text' => $task['name'],
             'parent' => $task['parent_id'] > 0 ? $task['parent_id'] : $topId ,
             'start_date' => $task['begin'],
+            'end_date' => $task['end'],
             'duration' => $end->diffInDays($begin),
             'progress' => $progress,
             'assign_to' =>$task['assign']?User::query()->where('id',$task['assign'])->first()->name:null,

+ 28 - 0
app/Tools/ApiPaginator.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Tools;
+
+use Illuminate\Pagination\LengthAwarePaginator;
+
+class ApiPaginator extends LengthAwarePaginator
+{
+
+    public function toArray()
+    {
+        return [
+            'current_page' => $this->currentPage(),
+            'data' => $this->items->toArray(),
+            'first_page_url' => $this->url(1),
+            'from' => $this->firstItem(),
+            'last_page' => $this->lastPage(),
+            'last_page_url' => $this->url($this->lastPage()),
+            // 'links' => $this->linkCollection()->toArray(),
+            'next_page_url' => $this->nextPageUrl(),
+            'path' => $this->path(),
+            'per_page' => $this->perPage(),
+            'prev_page_url' => $this->previousPageUrl(),
+            'to' => $this->lastItem(),
+            'total' => $this->total(),
+        ];
+    }
+}

+ 1 - 1
routes/api.php

@@ -62,6 +62,7 @@ Route::middleware(['auth:sanctum','account.limit'])->group(function () {
     Route::get("project-asset-tree/{project_id}", [API\ProjectController::class, "projectAssetTree"]);
     Route::get("project-requirementGroups-tree/{asset_id}", [API\ProjectController::class, "projectRequirementGroupsTree"]);
     Route::get("project/{project}/not-link-asset-requirement", [API\ProjectController::class, "notLinkAssetRequirement"]);
+    Route::get("library-linkage/{type}", [API\LibraryController::class, "linkage"]);
 
     // Allow access only to admin role
     Route::middleware(['permission', 'role.super-admin', 'system.operation-log'])->group(function () {
@@ -134,7 +135,6 @@ Route::middleware(['auth:sanctum','account.limit'])->group(function () {
         Route::post("approval/{approval}/action", [API\ApprovalController::class, 'action'])->name("approval.action");
         Route::patch("approval-cancel", [API\ApprovalController::class, 'cancel'])->name("approval.cancel");
 
-        Route::get("library-linkage/{type}", [API\LibraryController::class, "linkage"])->name("library.linkage");
 
         Route::get("asset/{asset}/dynamic", [API\AssetController::class, "dynamic"])->name("asset.dynamic");