main
Ilham Wara Nugroho 2025-10-01 14:35:24 +07:00
parent 5e8dd24894
commit 9a54d2cc53
3 changed files with 54 additions and 84 deletions

View File

@ -32,15 +32,26 @@ use SoftDeletes;
$years = $datasets->pluck('tahun')->toArray(); $years = $datasets->pluck('tahun')->toArray();
$model = self::with('dataset')->whereHas('dataset',function($query) use ($years){ $model = self::with('dataset')->whereHas('dataset',function($query) use ($years){
$query->whereIn('tahun',$years); $query->whereIn('tahun',$years);
})->where('dataset_id',$datasetId)->get(); })->where('dataset_id',$datasetId)->selectRaw('
SUM(tidak_sekolah_l) as ts_l,
$result = []; SUM(tidak_sekolah_p) as ts_p,
foreach ($model as $row) { SUM(sd_p) as dasar_p,
$lokasi = $row->lokasi ?? 'Unknown'; 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();
if (!isset($result[$lokasi])) { $result = [];
$result[$lokasi] = [ foreach ($model as $k => $row) {
'lokasi' => [], // $lokasi = $row->lokasi ?? 'Unknown';
if (!isset($result)) {
$result = [
'tidak_sekolah' => [], 'tidak_sekolah' => [],
'sd' => [], 'sd' => [],
'sltp' => [], 'sltp' => [],
@ -49,12 +60,11 @@ use SoftDeletes;
]; ];
} }
$result[$lokasi]['lokasi'][] = (float) $row->lokasi; $result[$k]['tidak_sekolah'][] = (float) $row->ts_l+(float) $row->ts_p;
$result[$lokasi]['tidak_sekolah'][] = (float) $row->tidak_sekolah_l+(float) $row->tidak_sekolah_p; $result[$k]['sd'][] = (float) $row->dasar_p+(float) $row->dasar_l;
$result[$lokasi]['sd'][] = (float) $row->sd_p+(float) $row->sd_l; $result[$k]['sltp'][] = (float) $row->smp_p+(float) $row->smp_l;
$result[$lokasi]['sltp'][] = (float) $row->sltp_p+(float) $row->sltp_l; $result[$k]['slta'][] = (float) $row->sma_p+(float) $row->sma_l;
$result[$lokasi]['slta'][] = (float) $row->slta_smk_p+(float) $row->slta_smk_l; $result[$k]['pt'][] = (float) $row->univ_p+(float) $row->univ_l;
$result[$lokasi]['pt'][] = (float) $row->pt_p+(float) $row->pt_l;
} }
return [ return [
@ -62,26 +72,26 @@ use SoftDeletes;
'years' => $years, 'years' => $years,
'yTitle' => 'Jumlah', 'yTitle' => 'Jumlah',
'yOpposite' => '', 'yOpposite' => '',
'series' => collect($result)->flatMap(function ($item, $lokasi) { 'series' => collect($result)->flatMap(function ($item) {
return [ return [
[ [
'name' => "Tidak Sekolah - {$lokasi}", 'name' => "Tidak Sekolah",
'type' => 'column', 'type' => 'column',
'data' => $item['tidak_sekolah'] 'data' => $item['tidak_sekolah']
],[ ],[
'name' => "SD - {$lokasi}", 'name' => "SD",
'type' => 'column', 'type' => 'column',
'data' => $item['sd'] 'data' => $item['sd']
],[ ],[
'name' => "SMP - {$lokasi}", 'name' => "SMP",
'type' => 'column', 'type' => 'column',
'data' => $item['sltp'] 'data' => $item['sltp']
],[ ],[
'name' => "SMA/SMK - {$lokasi}", 'name' => "SMA/SMK",
'type' => 'column', 'type' => 'column',
'data' => $item['slta'] 'data' => $item['slta']
],[ ],[
'name' => "Perguruan Tinggi - {$lokasi}", 'name' => "Perguruan Tinggi",
'type' => 'column', 'type' => 'column',
'data' => $item['pt'] 'data' => $item['pt']
], ],

View File

@ -64,39 +64,19 @@
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
</div> </div>
<div class="mb-3"> </div>
<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"> <div class="mb-3">
<label class="mb-3 required">Upload File</label> <label class="mb-3 required">Upload File</label>
<input type="file" accept=".xls,.xlsx" value="{{@$item->file ? @$item->file : old('file')}}" name="file" class="form-input @error('file') is-invalid @enderror" placeholder="Masukan File Dataset" {{@$item->file ? '' : 'required'}}> <input type="file" accept=".xls,.xlsx" value="{{@$item->file ? @$item->file : old('file')}}" name="file" class="form-input @error('file') is-invalid @enderror" placeholder="Masukan File Dataset" {{@$item->file ? '' : 'required'}}>
<small><i>Masukan Ekstensi File : .xls,.xlsx</i></small> <small><i>Masukan Ekstensi File : .xls,.xlsx</i></small>
@if(@$item->file) @if(@$item->file)
<br> <br>
<a href="{{asset('uploads/'.$item->file)}}" class="btn bg-success text-white mt-3"><i class="ri-download-line"></i>&nbsp;Download File</a> <a href="{{asset('uploads/'.$item->file)}}" class="btn bg-success text-white mt-3"><i class="ri-download-line"></i>&nbsp;Download File</a>
@endif @endif
@error('file') @error('file')
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
</div>
</div> </div>
<div class="mb-3"> <div class="mb-3">

View File

@ -65,39 +65,19 @@
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
</div> </div>
<div class="mb-3"> </div>
<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"> <div class="mb-3">
<label class="mb-3 required">Upload File</label> <label class="mb-3 required">Upload File</label>
<input type="file" accept=".xls,.xlsx" value="{{@$item->file ? @$item->file : old('file')}}" name="file" class="form-input @error('file') is-invalid @enderror" placeholder="Masukan File Dataset" {{@$item->file ? '' : 'required'}}> <input type="file" accept=".xls,.xlsx" value="{{@$item->file ? @$item->file : old('file')}}" name="file" class="form-input @error('file') is-invalid @enderror" placeholder="Masukan File Dataset" {{@$item->file ? '' : 'required'}}>
<small><i>Masukan Ekstensi File : .xls,.xlsx</i></small> <small><i>Masukan Ekstensi File : .xls,.xlsx</i></small>
@if(@$item->file) @if(@$item->file)
<br> <br>
<a href="{{asset('uploads/'.$item->file)}}" class="btn bg-success text-white mt-3"><i class="ri-download-line"></i>&nbsp;Download File</a> <a href="{{asset('uploads/'.$item->file)}}" class="btn bg-success text-white mt-3"><i class="ri-download-line"></i>&nbsp;Download File</a>
@endif @endif
@error('file') @error('file')
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
</div>
</div> </div>
<div class="mb-3"> <div class="mb-3">