mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
no message
This commit is contained in:
1 parent
2cc7224d21
commit
d2c718c5ea
2 files changed
+27
-2
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\MasterTaskResource;
|
||||
use App\Http\Resources\MasterTaskSimpleResource;
|
||||
use App\Models\Attachment;
|
||||
use App\Models\MasterTask;
|
||||
use App\Models\User;
|
||||
@@ -48,7 +49,7 @@ class MasterTaskController extends Controller
|
||||
|
||||
// vracia vsetky mastertasky v jednoduchom formate pre potreby dropdownu na FE (problem bol dlhy load time na zaciatku appky)
|
||||
case 'simple':
|
||||
$mastertasks = MasterTask::select('id', 'title');
|
||||
$mastertasks = MasterTask::select('id', 'title', 'project_id', 'color');
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -60,7 +61,7 @@ class MasterTaskController extends Controller
|
||||
$mastertasks = $mastertasks->get();
|
||||
|
||||
return response()->json([
|
||||
'mastertasks' => (isset($parameters['simple'])) ? $mastertasks : MasterTaskResource::collection($mastertasks)
|
||||
'mastertasks' => (isset($parameters['simple'])) ? MasterTaskSimpleResource::collection($mastertasks) : MasterTaskResource::collection($mastertasks)
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MasterTaskSimpleResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->title,
|
||||
'project_code' => ($this->project) ? $this->project->code . ' ' . $this->project->name : null,
|
||||
'color' => $this->color,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user