Skip to content

Instantly share code, notes, and snippets.

View ManojKiranA's full-sized avatar
🔍
Focusing

Manoj Kiran ManojKiranA

🔍
Focusing
  • Postiefs Technologies Private Limited
  • Coimbatore
View GitHub Profile
<?php
namespace App\Traits;
use Carbon\Carbon;
use Jenssegers\Date\Date;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
trait HasTranslatedDates
{
@ManojKiranA
ManojKiranA / ColumnSortable.vue
Created August 26, 2019 12:42 — forked from andrii-trush/ColumnSortable.vue
VueJS component for Laravel pagination + column sortable (https://github.com/Kyslik/column-sortable)
<template>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="text-nowrap">
<a href="#" @click.prevent="sortChange('name')">
<span>Name</span>
<i class="fa" :class="getClass('name', 'alpha')"></i>
</a>

$relations = [];

    $reflextionClass = new \ReflectionClass(TravelRequest::class);

    foreach($reflextionClass->getMethods() as $method) 
    {
        $doc = $method->getDocComment();

        $relations[$method->name] =  Str::contains((new \ReflectionMethod(TravelRequest::class, $method->name))->getDocComment(),['\Illuminate\Database\Eloquent\Relations']);
@ManojKiranA
ManojKiranA / short-number-format.php
Created August 30, 2019 19:55 — forked from RadGH/short-number-format.php
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
function computeDiff($from, $to)
{
    $diffValues = array();
    $diffMask = array();

    $dm = array();
    $n1 = count($from);
    $n2 = count($to);

for ($j = -1; $j < $n2; $j++) $dm[-1][$j] = 0;

@ManojKiranA
ManojKiranA / HttpCode.php
Created September 13, 2019 14:49 — forked from Yentel/HttpCode.php
PHP Class with all HTTP Status codes (Laravel)
<?php
namespace App\Http;
class HttpCode
{
/*
* HTTP Status Codes & their meaning
* Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
* By: Yentel Hollebeke - https://github.com/yentel
@ManojKiranA
ManojKiranA / LaravelEvents.md
Last active September 27, 2019 11:17
List of Events Available in the Laravel Framework

A Complete List Of Laravel Events

Auth

Illuminate\Auth\Events\Registered
Illuminate\Auth\Events\Attempting
Illuminate\Auth\Events\Authenticated
Illuminate\Auth\Events\Login
Illuminate\Auth\Events\Failed

Illuminate\Auth\Events\Logout

function determineNumberofChunk(int $dataCount,int $numberOfItemsPerChunk)
{
    $size = (int) ceil($dataCount / $numberOfItemsPerChunk);

    if ($size <= 0 ||  $dataCount === $numberOfItemsPerChunk) {
        return 1;
    }
    return $size;

}

  function calculateForPercentage($actual,$total,$convertForPercentage = 100)
{
    return (($actual/$total)*$convertForPercentage);
}

Route::get('/test', function () {

$callback = function (){
    $days=0; 
@ManojKiranA
ManojKiranA / LaravelResource.md
Created October 11, 2019 05:40
Laravel Api Recource
    <?php

    namespace App\Http\Resources\User;

    use Illuminate\Http\Resources\Json\JsonResource;
    use Illuminate\Http\Resources\Json\ResourceCollection;

    class UserPaginatedResource extends ResourceCollection
    {

public static $wrap = 'data';