Skip to content

Instantly share code, notes, and snippets.

View ajay-ag's full-sized avatar
🎯
Focusing

Ajay Gadhiya ajay-ag

🎯
Focusing
View GitHub Profile
@ajay-ag
ajay-ag / Filter.js
Created September 4, 2020 06:01
Search And Filter array for vue.js
//productList = array of object
let productList = [{
Price: 500 , ProductName : "Test"
},{
Price: 200 , ProductName : "Test -2"
}];
if (this.searchKey != "") {
productList = this.products.filter((post) => {
return post.ProductName.toLowerCase().includes(
@ajay-ag
ajay-ag / ArrayToJson.js
Created July 6, 2020 10:00
Convert multi-dimension array to json
(function ($) {
$.fn.serializeObject = function () {
var self = this,
json = {},
push_counters = {},
patterns = {
"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
"push": /^$/,
$.validator.addMethod("pan", function (value, element) {
return this.optional(element) || /^[A-Z]{5}\d{4}[A-Z]{1}$/.test(value);
}, "Please enter a valid PAN");
$.validator.addMethod("gst", function (value, element) {
return this.optional(element) || /^([0]{1}[1-9]{1}|[1-2]{1}[0-9]{1}|[3]{1}[0-7]{1})([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/.test(value);
}, "Please enter a valid GST No");
$.validator.addMethod('filesize', function (value, element, param) {
if (element.files.length) {
@ajay-ag
ajay-ag / Helper.php
Last active September 10, 2020 05:28
Image Upload Helper For Laravel
<?php
use Storage;
if (!function_exists('uploadImage')) {
function uploadImage($image, $dir, $unlink = null)
{
$request = request();
@ajay-ag
ajay-ag / Helper.php
Last active June 12, 2020 12:10
Date Format Helpler Laravel
<?php
if(!function_exists('dateformat')){
function dateformat($date , $format=null ) {
$setting = Cache::remember('default_setting',600 ,function () {
return \DB::table('settings')->first();
});
@ajay-ag
ajay-ag / Laravel And Alpine Pagination
Last active September 17, 2023 16:24
Laravel And Alpinej.js Pagination Component ,Alpine js
<div class="container-fluid">
<div class="row">
<!-- /.col-md-6 -->
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="row" id="laravelPagination" data-url="{{ route('country.page') }}" x-data="laravelPagination()"
x-init="init()">
<template x-for="item in country" :key="item.id">
<div class="card col-12 mb-3">