init project
This commit is contained in:
26
app/Http/Resources/AntibioticResource.php
Normal file
26
app/Http/Resources/AntibioticResource.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AntibioticResource 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_en' => $this->name_en,
|
||||
'weight' => $this->weight,
|
||||
'lab_id' => $this->lab_id,
|
||||
// 'lab' => LaboratoryResource::collection($this->lab),
|
||||
'record_status_id' => $this->record_status_id
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/HeadingItemResource.php
Normal file
27
app/Http/Resources/HeadingItemResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class HeadingItemResource 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 [
|
||||
'sample_id' => $this->id,
|
||||
'sample_type_id' => $this->sample_type_id,
|
||||
'group_result' => $this->group_result,
|
||||
'id' => $this->test_id,
|
||||
'name_en' => $this->whenLoaded('test', function (){
|
||||
return $this->test->name_en;
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Resources/LaboratoryResource.php
Normal file
24
app/Http/Resources/LaboratoryResource.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class LaboratoryResource 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_en' => $this->name_en,
|
||||
'name_kh' => $this->name_kh,
|
||||
'record_status_id' => $this->record_status_id
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Http/Resources/OrganismResource.php
Normal file
19
app/Http/Resources/OrganismResource.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrganismResource 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 parent::toArray($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Resources/PatientSampleResource.php
Normal file
19
app/Http/Resources/PatientSampleResource.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PatientSampleResource 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 parent::toArray($request);
|
||||
}
|
||||
}
|
||||
43
app/Http/Resources/SampleResource.php
Normal file
43
app/Http/Resources/SampleResource.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SampleResource 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,
|
||||
'sample_number' => $this->sample_number,
|
||||
'patient' => $this->whenLoaded('patient', function (){
|
||||
return [
|
||||
'id' => $this->patient->id,
|
||||
'uuid' => $this->patient->patient_uuid,
|
||||
'name' => $this->patient->name_en
|
||||
];
|
||||
}),
|
||||
'sample_source' => $this->whenLoaded('sample_source',function (){
|
||||
return [
|
||||
'id' => $this->sample_source->id,
|
||||
'name' => $this->sample_source->name_en
|
||||
];
|
||||
}),
|
||||
'physician' => $this->whenLoaded('physician',function (){
|
||||
return [
|
||||
'id' => $this->physician->id,
|
||||
'name' => $this->physician->name_en
|
||||
];
|
||||
}),
|
||||
'sample_details' => $this->whenLoaded('sample_details'),
|
||||
'sample_tests' => $this->whenLoaded('sample_tests')
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/SampleTestResource.php
Normal file
23
app/Http/Resources/SampleTestResource.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SampleTestResource 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 [
|
||||
'department_id' => $this->id,
|
||||
'department_name' => $this->name_en,
|
||||
'samples' => SampleTypeResource::collection($this->whenLoaded('samples')),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/SampleTypeResource.php
Normal file
31
app/Http/Resources/SampleTypeResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SampleTypeResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
$data = TestResource::collection($this->whenLoaded('testSamples'));
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'department_id' => $this->department_id,
|
||||
'name_en' => $this->name_en,
|
||||
'tube' => (string)$this->tube,
|
||||
'descriptions' => json_decode($this->description),
|
||||
'bg_color' => $this->bg_color,
|
||||
'color' => $this->color,
|
||||
'testSamples' => TestResource::collection($this->whenLoaded('testSamples')),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/TestResource.php
Normal file
31
app/Http/Resources/TestResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TestResource 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' => (string) $this->id,
|
||||
'group_result' => $this->group_result,
|
||||
'closed_parent_id' => (string) ($this->heading_id > 0 ? $this->heading_id : 0),
|
||||
'code' => $this->code,
|
||||
'test_name' => $this->whenLoaded('test', function (){
|
||||
return $this->test->name_en;
|
||||
}),
|
||||
'children' => null,
|
||||
'price' => (string)$this->usd_price,
|
||||
'test_heading' => $this->field_type== 0 ? 'test-heading' : ''
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
59
app/Http/Resources/TestSampleResource.php
Normal file
59
app/Http/Resources/TestSampleResource.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TestSampleResource 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,
|
||||
'sample_type' => new SampleTypeResource($this->whenLoaded('sample')),
|
||||
'selected_organisms' => $this->whenLoaded('organisms', function() {
|
||||
return $this->organisms->map(function ($item){
|
||||
return array(
|
||||
'id' => $item->id,
|
||||
'is_default' => $item->is_default,
|
||||
'organism_id' => $item->organism_id,
|
||||
'test_sample_id' => $item->test_sample_id,
|
||||
'organism' => $item->organism,
|
||||
);
|
||||
});
|
||||
}),
|
||||
'test_values' => $this->whenLoaded('testValues', function (){
|
||||
return $this->testValues->map(function ($item){
|
||||
return array(
|
||||
'id' => $item->id,
|
||||
'patient_type_id' => $item->patient_type_id,
|
||||
'sign' => $item->sign,
|
||||
'maximum' => $item->maximum,
|
||||
'minimum' => $item->minimum
|
||||
);
|
||||
});
|
||||
}),
|
||||
'test_id' => $this->test_id,
|
||||
'heading_id' => $this->heading_id,
|
||||
'usd_price' => $this->usd_price,
|
||||
'group_result' => $this->group_result,
|
||||
'category' => $this->category,
|
||||
'unit_sign' => $this->unit_sign,
|
||||
'weight' => $this->weight,
|
||||
'field_type' => $this->field_type,
|
||||
'format' => $this->format,
|
||||
'formula' => $this->formula,
|
||||
'description' => $this->description,
|
||||
'lab_id' => $this->lab_id,
|
||||
'code' => $this->code,
|
||||
'is_bold' => (int) $this->is_bold,
|
||||
'autocomplete_bind' => (int) $this->autocomplete_bind
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/UserResource.php
Normal file
31
app/Http/Resources/UserResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
try{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'is_manager' => $this->is_manager,
|
||||
'role_id' => $this->role_id
|
||||
];
|
||||
}
|
||||
catch(\Exception $e){
|
||||
return [];
|
||||
//dd($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user