first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RubrikResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$syaratsDb = $this->syarats->pluck('nama');
|
||||
$syarats = [];
|
||||
foreach ($syaratsDb as $syarat) {
|
||||
if (in_array(ucwords($syarat), ['Melalui Proses Review', 'Terdaftar Di Sim Lppm'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->id === 660 && ucwords($syarat) === 'Laporan Kegiatan') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = str_replace(' ', '_', $syarat);
|
||||
if (defined("App\Enums\Syarats::$key")) {
|
||||
$syarats[] = constant("App\Enums\Syarats::$key");
|
||||
} else {
|
||||
$syarats[] = ucwords($syarat);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'periode' => $this->periode_id,
|
||||
'kategori' => [
|
||||
'id' => $this->kategori->id,
|
||||
'nama' => $this->kategori->nama,
|
||||
],
|
||||
'uraian' => $this->uraian,
|
||||
'satuan' => $this->satuan->nama,
|
||||
'keterangan' => $this->keterangan ?? '-',
|
||||
'pelaksana' => RubrikDetailResource::collection($this->details),
|
||||
'syarats' => $syarats,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user