Skip to content

Instantly share code, notes, and snippets.

View Aslam97's full-sized avatar
🎯
Focusing

Aslam Aslam97

🎯
Focusing
  • Full-Stack Web Developer
  • Bandung, Jawa Barat, Indonesia
  • 20:23 (UTC +07:00)
  • X @__asuramus
View GitHub Profile
@Aslam97
Aslam97 / laravel_change_user_password.md
Last active October 11, 2021 13:54
Laravel change user password

Laravel change user password

Create Custom Validation Rules

  • Create CheckPassword rules

php artisan make:rule CheckPassword

use Illuminate\Contracts\Validation\Rule;
@Aslam97
Aslam97 / laravel_latitude_longitude_radius_max_distance.md
Last active May 7, 2020 16:43
Display data with the maximum distance using latitude and longitude

Example showing Product with max distance radius from latitude and longitude

  • Model Query Scope
    public function scopeIsWithinMaxDistance($query, $latitude, $longitude, $radius = 25)
    {
        // for miles you'd use 3961 instead of 6371 (Kilometer)
        $sql = "(6371 * acos(cos(radians($latitude))
                        * cos(radians(address.latitude))
                        * cos(radians(address.longitude)
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Route;
class CurrentRouteMiddleware
{
/**
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
class LangMiddleware
{
@Aslam97
Aslam97 / webpack.mix.js
Last active October 13, 2020 17:58
Laravel Mix webpack.mix.js simple configuration
const path = require("path");
const mix = require("laravel-mix");
mix.alias({
"@": path.join(__dirname, "resources/js"),
"~": path.join(__dirname, "resources/sass"),
});
mix
.js("resources/js/app.js", "public/js")
@Aslam97
Aslam97 / webpack.mix.js
Last active October 29, 2020 09:06
Laravel Mix css module
// this project uses laravel Mix Version 6 and webpack 5
// to solve this problem https://github.com/JeffreyWay/laravel-mix/issues/1889
// for laravel Mix version 5 that you still want to use extract with dynamic-import please read my article
// https://medium.com/@iupin5212/bagaimana-codesplitting-di-laravel-mix-389fc76e37ae
// for list of npm command please refer to package.json
// react [name]__[local]___[hash:base64:5]
// discord [local]-[hash:base64:5]
@Aslam97
Aslam97 / vue_currency_format_rupiah_indonesia.js
Created October 16, 2020 16:29
Change format price to rupiah using vue.js
Vue.component('idr', {
template: '<input type="text" v-model="currentValue" @input="handleInput" />',
props: {
value: {
type: [String, Number],
default: ""
},
},
data: () => ({
currentValue: ''
@Aslam97
Aslam97 / webpack.mix.js
Created October 29, 2020 18:19
Laravel mix 5 webpack.mix.js
const path = require("path");
const mix = require("laravel-mix");
require("laravel-mix-vue-css-modules"); // https://github.com/Aslam97/laravel-mix-vue-css-modules
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const purgeCss = mix.inProduction()
? [
require("@fullhuman/postcss-purgecss")({
content: ["resources/**/*.blade.php", "resources/**/*.vue"],
defaultExtractor(content) {
@Aslam97
Aslam97 / routes.js
Created October 29, 2020 18:25
Vue dynamic import
// Lazy-loads view components, but with better UX. A loading view
// will be used if the component takes a while to load, falling
// back to a timeout view in case the page fails to load. You can
// use this component to lazy-load a route with:
//
// component: () => lazyLoadView(import('@views/my-view'))
//
// NOTE: Components loaded with this strategy DO NOT have access
// to in-component guards, such as beforeRouteEnter,
// beforeRouteUpdate, and beforeRouteLeave. You must either use
@Aslam97
Aslam97 / github_init.md
Created March 18, 2021 07:20
Git init github

##…or create a new repository on the command line

echo "# laravel-bank-bni" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Aslam97/laravel-bank-bni.git
git push -u origin main