update
parent
5e8dd24894
commit
9a54d2cc53
|
|
@ -32,15 +32,26 @@ use SoftDeletes;
|
|||
$years = $datasets->pluck('tahun')->toArray();
|
||||
$model = self::with('dataset')->whereHas('dataset',function($query) use ($years){
|
||||
$query->whereIn('tahun',$years);
|
||||
})->where('dataset_id',$datasetId)->get();
|
||||
})->where('dataset_id',$datasetId)->selectRaw('
|
||||
SUM(tidak_sekolah_l) as ts_l,
|
||||
SUM(tidak_sekolah_p) as ts_p,
|
||||
SUM(sd_p) as dasar_p,
|
||||
SUM(sd_l) as dasar_l,
|
||||
SUM(sltp_p) as smp_p,
|
||||
SUM(sltp_l) as smp_l,
|
||||
SUM(slta_smk_p) as sma_p,
|
||||
SUM(slta_smk_l) as sma_l,
|
||||
SUM(pt_l) as univ_l,
|
||||
SUM(pt_p) as univ_p
|
||||
')->get();
|
||||
// Sekolah::selectRaw('SUM(jumlah_siswa) as total_siswa, SUM(jumlah_guru) as total_guru')->first();
|
||||
|
||||
$result = [];
|
||||
foreach ($model as $row) {
|
||||
$lokasi = $row->lokasi ?? 'Unknown';
|
||||
foreach ($model as $k => $row) {
|
||||
// $lokasi = $row->lokasi ?? 'Unknown';
|
||||
|
||||
if (!isset($result[$lokasi])) {
|
||||
$result[$lokasi] = [
|
||||
'lokasi' => [],
|
||||
if (!isset($result)) {
|
||||
$result = [
|
||||
'tidak_sekolah' => [],
|
||||
'sd' => [],
|
||||
'sltp' => [],
|
||||
|
|
@ -49,12 +60,11 @@ use SoftDeletes;
|
|||
];
|
||||
}
|
||||
|
||||
$result[$lokasi]['lokasi'][] = (float) $row->lokasi;
|
||||
$result[$lokasi]['tidak_sekolah'][] = (float) $row->tidak_sekolah_l+(float) $row->tidak_sekolah_p;
|
||||
$result[$lokasi]['sd'][] = (float) $row->sd_p+(float) $row->sd_l;
|
||||
$result[$lokasi]['sltp'][] = (float) $row->sltp_p+(float) $row->sltp_l;
|
||||
$result[$lokasi]['slta'][] = (float) $row->slta_smk_p+(float) $row->slta_smk_l;
|
||||
$result[$lokasi]['pt'][] = (float) $row->pt_p+(float) $row->pt_l;
|
||||
$result[$k]['tidak_sekolah'][] = (float) $row->ts_l+(float) $row->ts_p;
|
||||
$result[$k]['sd'][] = (float) $row->dasar_p+(float) $row->dasar_l;
|
||||
$result[$k]['sltp'][] = (float) $row->smp_p+(float) $row->smp_l;
|
||||
$result[$k]['slta'][] = (float) $row->sma_p+(float) $row->sma_l;
|
||||
$result[$k]['pt'][] = (float) $row->univ_p+(float) $row->univ_l;
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
@ -62,26 +72,26 @@ use SoftDeletes;
|
|||
'years' => $years,
|
||||
'yTitle' => 'Jumlah',
|
||||
'yOpposite' => '',
|
||||
'series' => collect($result)->flatMap(function ($item, $lokasi) {
|
||||
'series' => collect($result)->flatMap(function ($item) {
|
||||
return [
|
||||
[
|
||||
'name' => "Tidak Sekolah - {$lokasi}",
|
||||
'name' => "Tidak Sekolah",
|
||||
'type' => 'column',
|
||||
'data' => $item['tidak_sekolah']
|
||||
],[
|
||||
'name' => "SD - {$lokasi}",
|
||||
'name' => "SD",
|
||||
'type' => 'column',
|
||||
'data' => $item['sd']
|
||||
],[
|
||||
'name' => "SMP - {$lokasi}",
|
||||
'name' => "SMP",
|
||||
'type' => 'column',
|
||||
'data' => $item['sltp']
|
||||
],[
|
||||
'name' => "SMA/SMK - {$lokasi}",
|
||||
'name' => "SMA/SMK",
|
||||
'type' => 'column',
|
||||
'data' => $item['slta']
|
||||
],[
|
||||
'name' => "Perguruan Tinggi - {$lokasi}",
|
||||
'name' => "Perguruan Tinggi",
|
||||
'type' => 'column',
|
||||
'data' => $item['pt']
|
||||
],
|
||||
|
|
|
|||
|
|
@ -64,25 +64,6 @@
|
|||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="mb-3 required">Tags / Kata Kunci</label>
|
||||
<div id="tag-container" class="flex flex-wrap gap-2 p-2 form-input rounded bg-white focus-within:ring-2 ring-blue-500">
|
||||
<?php
|
||||
$tag = @json_decode(@$item->tags);
|
||||
?>
|
||||
@if(@$tag)
|
||||
@foreach($tag as $dataTags)
|
||||
@if(@$dataTags)
|
||||
<span class="inline-flex items-center px-2 py-1 bg-primary text-white text-sm rounded">{{@$dataTags}} <button type="button" class="ml-1 text-blue-500 hover:text-red-600">×</button><input type="hidden" name="tags[]" value="{{@$dataTags}}"></span>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
<input id="tag-input" type="text" value="" name="tags[]" placeholder="Tambah tag..." class="flex-grow border-none p-1 text-sm" />
|
||||
</div>
|
||||
<small><i>*Sesuaikan kata kunci dengan dataset Anda</i></small>
|
||||
@error('tags')
|
||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
|
@ -97,7 +78,6 @@
|
|||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="mb-3 required">Deskripsi Dataset</label>
|
||||
|
|
|
|||
|
|
@ -65,25 +65,6 @@
|
|||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="mb-3 required">Tags / Kata Kunci</label>
|
||||
<div id="tag-container" class="flex flex-wrap gap-2 p-2 form-input rounded bg-white focus-within:ring-2 ring-blue-500">
|
||||
<?php
|
||||
$tag = @json_decode(@$item->tags);
|
||||
?>
|
||||
@if(@$tag)
|
||||
@foreach($tag as $dataTags)
|
||||
@if(@$dataTags)
|
||||
<span class="inline-flex items-center px-2 py-1 bg-primary text-white text-sm rounded">{{@$dataTags}} <button type="button" class="ml-1 text-blue-500 hover:text-red-600">×</button><input type="hidden" name="tags[]" value="{{@$dataTags}}"></span>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
<input id="tag-input" type="text" value="" name="tags[]" placeholder="Tambah tag..." class="flex-grow border-none p-1 text-sm" />
|
||||
</div>
|
||||
<small><i>*Sesuaikan kata kunci dengan dataset Anda</i></small>
|
||||
@error('tags')
|
||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
|
|
@ -98,7 +79,6 @@
|
|||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="mb-3 required">Deskripsi Dataset</label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue