Recent Posts

Laravel Return Response JSON Error Message on Ajax
//Controller try { //YOUR CODE HERE... return response()->json(['message'=>'Success!']); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()], 500); } //HTML $.ajax({ type:'POST', url:'/thisurl', data:{name:name}, success:function(data){ //Swal.close(); alert(data.message); }, error:function(data) { var errors = data.responseJSON; alert(errors.message); //Swal.close(); } });

Menghitung Hari Antara Dua Tanggal Pada Javascript
Menghitung atau Mendapatkan Jumlah Hari Antara Dua Tanggal Pada Javascript <script> function countHari(date1, date2) { //date1 = 11-09-2021 //date2 = 08-10-2021 //Pertama kita membagi nilai ke array date1[0] adalah hari, [1] bulan dan [2] tahun date1 = date1.split('-'); date2 = date2.split('-'); const oneDay = 24 * 60 * 60 * 1000; //hours*minutes*seconds*milliseconds //JavaScript menghitung bulan dari 0 sampai 11. dimana 0 = Januari, 1 = Februari, dst //Sehingga kita harus mengurangi nilai 1 pada value Bulan date1[1] const firstDate = new Date(date1[2], date1[1]-1, date1[0]); //Date(2021, 09, 11) const secondDate = new Date(date2[2], date2[1]-1, date2[0]); //Date(2021, 10, 08) const diffDays = Math.round(Math.abs((firstDate - secondDate) / oneDay)); return diffDays; } function countFunction() { const jumlahHari = countHari('11-09-2021', '08-10-2021'); alert(jumlahHari); } </script>

Contoh Penerapan Pivot Table Pada Laravel
Hari ini kita membahas tentang fitur Laravel yang sangat berguna tetapi pada awalnya mungkin sulit untuk dipahami. Tabel pivot (Pivot Tables) adalah contoh tabel perantara dengan hubungan antara dua tabel “utama” lainnya atau istilahnya Many to Many Relationships. Pada tutorial ini saya akan mengambil contoh antara user dan role, dimana satu user dapat memiliki banyak role dan sebaliknya satu role dapat dimiliki oleh banyak user, maka kita membutuhkan satu tabel tambahan bernama role_user, nah table role_user inilah yang disebut sebagai pivot table atau table perantara. Aturan penulisan pivot table yang benar adalah sesuai abjad masing-masing table yang ingin kita hubungkan, misalnya Role dan User diawali dengan huruf “R” dan “U” maka sesuai abjad adalah “R” yang lebih dulu daripada huruf “S”, maka tabel penghubungnya (Pivot Table) bisa kita buat menjadi role_user. Jadi, di bawah ini adalah struktur database yang akan kita terapkan: users – id – name – email – password roles – id – name role_user – user_id – role_id Kita sudah mengetahui struktur table yang ingin kita buat, selanjutnya buatlah migrasi database terlebih dahulu. //users table public function up() { Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->timestamps(); }); } //roles table public function up() { Schema::create('roles', function (Blueprint $table) { $table->id(); $table->string('name', 30)->unique(); }); } //role_user table harus sesuai abjad lebih dulu public function up() { Schema::create('role_user', function (Blueprint $table) { $table->id(); $table->bigInteger('role_id')->unsigned(); $table->foreign('role_id') ->references('id')->on('roles') ->onDelete('cascade'); $table->bigInteger('user_id')->unsigned(); $table->foreign('user_id') ->references('id')->on('users') ->onDelete('cascade'); }); } app/Models/User.php protected $table = 'users'; public function roles() { return $this->belongsToMany(App\Models\Role::class); } app/Models/Role.php protected $table = 'roles'; public $timestamps = false; public function users() { return $this->belongsToMany(App\Models\User::class); } app/Models/RoleUser.php protected $table = 'role_user'; public $timestamps = false; Controller use Illuminate\Support\Facades\DB; public function create() { $roles = Role::select('id', 'name')->get(); return view('users.create', compact('roles')); } public function store(Request $request) { $request->validate([ 'name'=>'required|string|max:100',.

Cara setting SSL Let's Encrypt di Webmin Virtualmin LAMPP
Cara setting SSL Let’s Encrypt di Webmin/Virtualmin/LAMPP 1. Buka Webmin – Webmin Configuration – SSL Encryption – Pilih Tab Let’s Encrypt 2. Isi Hostnames for certificate dengan nama domain, contoh: maincit.net 3. Isi Other directory (Directory Home index.php website): /opt/lampp/htdocs 4. Isi Months between automatic renewal: 2 (Artinya 2 bulan sekali diperbarui) 5. Klik Request Certificate dan tunggu sampai sukses, jika error klik ulang Request Certificate 6. Edit file /opt/lampp/etc/extra/httpd-ssl.conf (Isi sesuai yg di Webmin Configuration – SSL Encryption – SSL Settings) SSLEngine on SSLCertificateFile “/etc/webmin/letsencrypt-cert.pem” SSLCertificateKeyFile “/etc/webmin/letsencrypt-key.pem” 7. Restart lampp: /opt/lampp/lampp restart 8. Restart Webmin 9. Selesai.

Membuat Symbolic Link (Symlink) di Windows 10
Untuk membuat Symbolic Link atau Symlink di Windows 10 caranya adalah sebagai berikut: Install https://docs.microsoft.com/en-us/sysinternals/downloads/junction jika belum terinstall Buka CMD run admin lalu ketikkan perintah dibawah: mklink /D "C:\xampp\htdocs\app\public\storage" "C:\xampp\htdocs\app\storage\app\public" Keterangan: 1. Direktori pertama (C:\xampp\htdocs\app\public\storage) adalah file baru yang akan tercipta dan mengarah ke direktori kedua. 2. Direktori kedua (C:\xampp\htdocs\app\storage\app\public) adalah direktori tujuan atau direktori yang asli.
Subscribe To Us !
Here you will find all the different ways to stay up to date with the newest articles on our website.