Commit 935276dc by Farendi Giotivano R.P

ganti kelompok

parent 63fa1098
......@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Controllers\GetDataApiController;
use Illuminate\Http\Request;
class DosenController extends Controller
......@@ -16,30 +17,37 @@ class DosenController extends Controller
$total_count = 0;
$incomplete_results = true;
$items = array();
if ($getDosen->isEmpty()) {
$items = [];
if (empty($getDosen)) {
$items = array();
} else {
$no = 0;
foreach ($getDosen as $item) {
$items[$item->id]['nm_sdm'] = $item->nm_sdm;
$items[$item->id]['nm_sdm'] = $item->prodi;
$items[$item->id]['nm_sdm'] = $item->nidn;
foreach ($getDosen['data'] as $key => $item) {
if(str_contains(strtolower($item['nm_sdm']), strtolower($keyword))){
$itemData = [
'id' => encrypt($item['id_sdm'].'_'.$item['nm_sdm'].'_'.$item['nidn']),
'full_name' => $item['nm_sdm'],
'description' => $item['prodi'],
'nidn' => $item['nidn'],
];
$items[] = $itemData;
$total_count = $total_count + 1;
}
}
}
$data = [
'total_count' => $total_count,
'incomplete_results' => false,
'items' => $items,
];
//dd($data);
return response()->json($data);
return response($data, 200);
}
}
......@@ -71,6 +71,7 @@ class KelompokController extends Controller
$getDosen = GetDataApiController::getDosen();
$periode = Periode::query()->where('status', 1)->first();
$data = [
'title' => $title,
'dosen' => $getDosen['data'],
......@@ -140,7 +141,7 @@ class KelompokController extends Controller
'created_user' => Auth::user()->id
]);
return redirect()->intended(route('mahasiswa.kelompok.createnew', ['id' => encrypt($kel->kelompok_id)]))->with('success', 'Berhasil membuat elompok!');
return redirect()->intended(route('mahasiswa.kelompok.createnew', ['id' => encrypt($kel->kelompok_id)]))->with('success', 'Berhasil membuat Kelompok!');
}
/**
......
......@@ -36,11 +36,8 @@
<label class="col-sm-2 col-form-label">Dosen Pembimbing</label>
<div class="col-sm-10">
<input type="hidden" name="periode" value="{{ $periode['periode_id'] }}" >
<select class="form-select select2" name="dosen">
<option selected>Pilih Dosen</option>
@foreach($dosen as $item)
<option value="{{ encrypt($item['id_sdm'].'_'.$item['nm_sdm'].'_'.$item['nidn']) }}">{{ $item['nm_sdm'].' - '.$item['prodi']}}</option>
@endforeach
<select class="form-select" id="selectDosen" name="dosen">
</select>
</div>
</div>
......@@ -65,7 +62,64 @@
@section('js')
<script>
$(document).ready(function() {
$(".select2").select2();
$("#selectDosen").select2({
ajax: {
url: "{{ route('api.getDosen') }}",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data, params) {
// parse the results into the format expected by Select2
// since we are using custom formatting functions we do not need to
// alter the remote JSON data, except to indicate that infinite
// scrolling can be used
params.page = params.page || 1;
return {
results: data.items,
pagination: {
more: (params.page * 30) < data.total_count
}
};
},
cache: true
},
placeholder: 'Pilih Dosen Pembimbing',
minimumInputLength: 1,
templateResult: formatRepo,
templateSelection: formatRepoSelection
});
});
function formatRepo (repo) {
if (repo.loading) {
return repo.text;
}
var $container = $(
"<div class='select2-result-repository clearfix'>" +
"<div class='select2-result-repository__meta'>" +
"<div class='select2-result-repository__title'></div>" +
"<div class='select2-result-repository__description'></div>" +
"</div>" +
"</div>"
);
$container.find(".select2-result-repository__title").text(repo.full_name);
$container.find(".select2-result-repository__description").text(repo.description);
return $container;
}
function formatRepoSelection (repo) {
return repo.full_name || repo.text;
}
</script>
@endsection
......@@ -248,39 +248,5 @@
}
function formatRepo (repo) {
if (repo.loading) {
return repo.text;
}
var $container = $(
"<div class='select2-result-repository clearfix'>" +
"<div class='select2-result-repository__avatar'><img src='" + repo.owner.avatar_url + "' /></div>" +
"<div class='select2-result-repository__meta'>" +
"<div class='select2-result-repository__title'></div>" +
"<div class='select2-result-repository__description'></div>" +
"<div class='select2-result-repository__statistics'>" +
"<div class='select2-result-repository__forks'><i class='fa fa-flash'></i> </div>" +
"<div class='select2-result-repository__stargazers'><i class='fa fa-star'></i> </div>" +
"<div class='select2-result-repository__watchers'><i class='fa fa-eye'></i> </div>" +
"</div>" +
"</div>" +
"</div>"
);
$container.find(".select2-result-repository__title").text(repo.full_name);
$container.find(".select2-result-repository__description").text(repo.description);
$container.find(".select2-result-repository__forks").append(repo.forks_count + " Forks");
$container.find(".select2-result-repository__stargazers").append(repo.stargazers_count + " Stars");
$container.find(".select2-result-repository__watchers").append(repo.watchers_count + " Watchers");
return $container;
}
function formatRepoSelection (repo) {
return repo.full_name || repo.text;
}
</script>
@endsection
<?php
use App\Http\Controllers\Api\DosenController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
......@@ -17,3 +18,7 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
Route::group(['namespace' => 'Api'], function () {
Route::get('getDosen', [DosenController::class, 'getDosen'])->name('api.getDosen');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment