48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Resources;
|
||
|
|
|
||
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
|
|
||
|
|
class DocumentResource extends JsonResource
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Transform the resource into an array.
|
||
|
|
*
|
||
|
|
* @param \Illuminate\Http\Request $request
|
||
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||
|
|
*/
|
||
|
|
public function toArray($request)
|
||
|
|
{
|
||
|
|
switch ($this->lang) {
|
||
|
|
case 1:
|
||
|
|
$tmpLang = "fr";
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
$tmpLang = "en";
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
$tmpLang = "de";
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
$tmpLang = "nl";
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
return [
|
||
|
|
'id' => $this->id,
|
||
|
|
'uuid' => $this->uuid,
|
||
|
|
'title' => $this->title,
|
||
|
|
'type' => $this->type,
|
||
|
|
'directory' => $this->directory_id,
|
||
|
|
'path' => $this->path,
|
||
|
|
'lang' => $tmpLang,
|
||
|
|
'published' => ($this->status) ? 1 : 0,
|
||
|
|
'parent' => $this->document_id,
|
||
|
|
'created_at' => $this->created_at,
|
||
|
|
'updated_at' => $this->updated_at,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|