Kode dari ftuntan_main dengan dependensi diperbarui untuk PHP 8.3 (perbaikan insiden 27 Okt 2026). Dump database di database/sql/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
227 lines
11 KiB
PHP
227 lines
11 KiB
PHP
@extends('admin/layout/main')
|
|
|
|
@section('title', 'Informasi Beasiswa')
|
|
|
|
@section('container')
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<div class="content-header">
|
|
<div class="container-fluid">
|
|
<div class="row mb-2">
|
|
<div class="col-sm-6">
|
|
<h1 class="m-0">Informasi Beasiswa</h1>
|
|
</div><!-- /.col -->
|
|
</div><!-- /.row -->
|
|
</div><!-- /.container-fluid -->
|
|
</div>
|
|
<!-- /.content-header -->
|
|
|
|
<!-- Main content -->
|
|
<section class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title">Edit Data Informasi Beasiswa</h3>
|
|
</div>
|
|
<!-- /.card-header -->
|
|
<div class="card-body">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<!-- form start -->
|
|
<form class="from-prevent-multiple-submits"
|
|
action="{{ route('informasi_beasiswa.update', $informasiBeasiswa) }}"
|
|
method="POST" enctype="multipart/form-data">
|
|
@method('patch')
|
|
@csrf
|
|
<div class="card-body">
|
|
<input type="hidden" value="{{ $informasiBeasiswa->id }}" name="id">
|
|
<div class="form-group">
|
|
<label for="judul">Judul</label>
|
|
<input type="text" class="form-control" id="judul" name="judul"
|
|
maxlength="255" placeholder="Masukkan Judul"
|
|
value="{{ $informasiBeasiswa->judul }}" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="nama_foto">Thumbnail (Maksimal 2MB)</label>
|
|
<div class="form-group">
|
|
<img src="{{ url($informasiBeasiswa->thumbnail) }}"
|
|
alt="Image Missing" id="old_nama_foto" style="max-width: 200px;"
|
|
class="mt-2" />
|
|
</div>
|
|
<input type="file" accept="image/*" class="form-control mt-0"
|
|
name="thumbnail" id="input_foto_edit">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="teks">Teks (Foto Maksimal 2MB)</label>
|
|
<textarea id="teks" placeholder="Masukkan Deskripsi Video"
|
|
name="teks">{{ $informasiBeasiswa->teks }}</textarea>
|
|
</div>
|
|
<div class="form-group mt-2">
|
|
<label for="release_date">Tanggal Rilis</label>
|
|
<input type="date" class="form-control mt-0" name="release_date"
|
|
value="{{ $informasiBeasiswa->release_date }}" required>
|
|
</div>
|
|
</div>
|
|
<!-- /.card-body -->
|
|
|
|
<div class="card-footer">
|
|
<button id="submit" type="submit"
|
|
class="btn btn-primary from-prevent-multiple-submits">Save</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<script>
|
|
//Define an adapter to upload the files
|
|
class MyUploadAdapter {
|
|
constructor(loader) {
|
|
// The file loader instance to use during the upload. It sounds scary but do not
|
|
// worry — the loader will be passed into the adapter later on in this guide.
|
|
this.loader = loader;
|
|
|
|
// URL where to send files.
|
|
this.url = '{{ route('ckeditor.upload') }}';
|
|
|
|
//
|
|
}
|
|
// Starts the upload process.
|
|
upload() {
|
|
return this.loader.file.then(
|
|
(file) =>
|
|
new Promise((resolve, reject) => {
|
|
this._initRequest();
|
|
this._initListeners(resolve, reject, file);
|
|
this._sendRequest(file);
|
|
})
|
|
);
|
|
}
|
|
// Aborts the upload process.
|
|
abort() {
|
|
if (this.xhr) {
|
|
this.xhr.abort();
|
|
}
|
|
}
|
|
// Initializes the XMLHttpRequest object using the URL passed to the constructor.
|
|
_initRequest() {
|
|
const xhr = (this.xhr = new XMLHttpRequest());
|
|
// Note that your request may look different. It is up to you and your editor
|
|
// integration to choose the right communication channel. This example uses
|
|
// a POST request with JSON as a data structure but your configuration
|
|
// could be different.
|
|
// xhr.open('POST', this.url, true);
|
|
xhr.open("POST", this.url, true);
|
|
xhr.setRequestHeader("x-csrf-token", "{{ csrf_token() }}");
|
|
xhr.responseType = "json";
|
|
}
|
|
// Initializes XMLHttpRequest listeners.
|
|
_initListeners(resolve, reject, file) {
|
|
const xhr = this.xhr;
|
|
const loader = this.loader;
|
|
const genericErrorText = `Couldn't upload file: ${file.name}.`;
|
|
xhr.addEventListener("error", () => reject(genericErrorText));
|
|
xhr.addEventListener("abort", () => reject());
|
|
xhr.addEventListener("load", () => {
|
|
const response = xhr.response;
|
|
// This example assumes the XHR server's "response" object will come with
|
|
// an "error" which has its own "message" that can be passed to reject()
|
|
// in the upload promise.
|
|
//
|
|
// Your integration may handle upload errors in a different way so make sure
|
|
// it is done properly. The reject() function must be called when the upload fails.
|
|
if (!response || response.error) {
|
|
return reject(response && response.error ? response.error.message : genericErrorText);
|
|
}
|
|
// If the upload is successful, resolve the upload promise with an object containing
|
|
// at least the "default" URL, pointing to the image on the server.
|
|
// This URL will be used to display the image in the content. Learn more in the
|
|
// UploadAdapter#upload documentation.
|
|
resolve({
|
|
default: response.url,
|
|
});
|
|
});
|
|
// Upload progress when it is supported. The file loader has the #uploadTotal and #uploaded
|
|
// properties which are used e.g. to display the upload progress bar in the editor
|
|
// user interface.
|
|
if (xhr.upload) {
|
|
xhr.upload.addEventListener("progress", (evt) => {
|
|
if (evt.lengthComputable) {
|
|
loader.uploadTotal = evt.total;
|
|
loader.uploaded = evt.loaded;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
// Prepares the data and sends the request.
|
|
_sendRequest(file) {
|
|
// Prepare the form data.
|
|
const data = new FormData();
|
|
data.append("upload", file);
|
|
// Important note: This is the right place to implement security mechanisms
|
|
// like authentication and CSRF protection. For instance, you can use
|
|
// XMLHttpRequest.setRequestHeader() to set the request headers containing
|
|
// the CSRF token generated earlier by your application.
|
|
// Send the request.
|
|
this.xhr.send(data);
|
|
}
|
|
// ...
|
|
}
|
|
|
|
function SimpleUploadAdapterPlugin(editor) {
|
|
editor.plugins.get("FileRepository").createUploadAdapter = (loader) => {
|
|
// Configure the URL to the upload script in your back-end here!
|
|
return new MyUploadAdapter(loader);
|
|
};
|
|
}
|
|
|
|
//Initialize the ckeditor
|
|
ClassicEditor.create(document.querySelector("#teks"), {
|
|
extraPlugins: [SimpleUploadAdapterPlugin],
|
|
}).catch((error) => {
|
|
console.error(error);
|
|
});
|
|
|
|
$("#ckeditorForm").submit(function(e) {
|
|
var content = $('.ck_editor_txt').val();
|
|
html = $(content).text();
|
|
if ($.trim(html) == '') {
|
|
alert("Teks Tidak Boleh Kosong!");
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
//Form edit image validation
|
|
var uploadField = document.getElementById("input_foto_edit");
|
|
uploadField.onchange = function() {
|
|
if (this.files[0].size > 2000000) {
|
|
alert("Batas maksimum 2MB!");
|
|
this.value = "";
|
|
} else {
|
|
//Ubah Img Preview
|
|
var reader = new FileReader();
|
|
reader.onload = function() {
|
|
var output = document.getElementById('old_nama_foto');
|
|
output.src = reader.result;
|
|
}
|
|
reader.readAsDataURL(event.target.files[0]);
|
|
};
|
|
};
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
(function() {
|
|
$('.from-prevent-multiple-submits').on('submit', function() {
|
|
$('.from-prevent-multiple-submits').attr('disabled', 'true');
|
|
})
|
|
})();
|
|
</script>
|
|
@endsection
|