Skip to content

Instantly share code, notes, and snippets.

View tuanama13's full-sized avatar
🎯
Focusing

Ambrosius Ama Tuan tuanama13

🎯
Focusing
View GitHub Profile
// App\Providers\AppServiceProvider
public function boot()
{
config(['app.locale' => 'id']);
Carbon::setLocale('id');
date_default_timezone_set('Asia/Jakarta');
}
@tuanama13
tuanama13 / Laravel-Scheduler-Windows.md
Created May 17, 2021 08:13 — forked from Splode/Laravel-Scheduler-Windows.md
Laravel Scheduler on Windows

Run Laravel Scheduled Tasks on Windows

The following are instructions for running scheduled tasks defined in a Laravel project on Windows. The Laravel documentation provides instructions for running scheduled tasks using cron jobs on Linux systems. However, cron jobs are not available on Windows. The built-in Windows Task Scheduler can be used to run scheduled tasks instead.

Create a Scheduled Task

  1. Open Task Scheduler
  2. Select Create Task...
  3. Give the task a name and description
  4. To run the task in the background, select Run whether the user is logged on or not and check the Hidden checkbox.
@tuanama13
tuanama13 / send OTP
Last active September 2, 2021 07:16
public function sendOTP($number, $appSignature)
{
if (! $number) {
return response()->json(['message' => 'Error! Empty Phone Number'], 400);
}
ob_start();
// setting
$apikey = 'API_KEY'; // api key
$urlendpoint = 'http://sms195.xyz/sms/api_sms_otp_send_json.php'; // url endpoint api
$callbackurl = 'http://localhost:8000/api/auth/callback-otp'; // url callback get status sms
@tuanama13
tuanama13 / UploadFile.php
Last active May 31, 2022 07:20
Laravel Upload File
<?php
if ($request->hasFile("image")) {
if (!Storage::exists('public/hotel/')) Storage::makeDirectory('public/hotel/');
$files = $request->file('image');
foreach ($files as $file) {
$image = ($file) ? $request->getSchemeAndHttpHost() . '/storage/' . $file->storeAs('public/hotel', 'hotel_'.time().rand(1, 1000). '_image.' . $file->getClientOriginalExtension()) : '';
$newPath = str_replace('public/', '', $image);
ImageHotel::create([
'hotel_id' => $hotel->id,
@tuanama13
tuanama13 / titleCaseWord.js
Last active May 31, 2022 07:18
Title Case Word
function titleCase(str) {
var splitStr = str.toLowerCase().split(' ');
for (var i = 0; i < splitStr.length; i++) {
// You do not need to check if i is larger than splitStr length, as your for does that for you
// Assign it back to the array
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
}
// Directly return the joined string
return splitStr.join(' ');
}