36 lines
807 B
PHP
36 lines
807 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Resources\API;
|
||
|
|
||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
|
||
|
class Setting extends JsonResource
|
||
|
{
|
||
|
/**
|
||
|
* Transform the resource into an array.
|
||
|
*
|
||
|
* @param \Illuminate\Http\Request $request
|
||
|
* @return array
|
||
|
*/
|
||
|
public function toArray($request)
|
||
|
{
|
||
|
$data = [
|
||
|
'name' => $this->name,
|
||
|
//'created_at' => $this->created_at,
|
||
|
//'updated_at' => $this->created_at,
|
||
|
'description' => $this->description,
|
||
|
'typ' => $this->typ,
|
||
|
'value' => $this->value,
|
||
|
];
|
||
|
|
||
|
if($this->typ == "checkbox") {
|
||
|
$data["value"] = (bool)$this->value;
|
||
|
}
|
||
|
|
||
|
if($this->typ == "password") {
|
||
|
$data["value"] = null;
|
||
|
}
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
}
|