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\Merge;
class Marge
{
protected $data = [];
public function setData($data)
{
@ManojKiranA
ManojKiranA / full.php
Last active December 21, 2021 01:39
Inertia Js Paginate
Route::get('/', function (\Illuminate\Http\Request $request) {
$initialSearch = $request->query('search', '');
$userQuery = User::query()
->when($request->filled('search'),function($query) use ($initialSearch){
$query->where('name','LIKE','%'.$initialSearch.'%')
->orWhere('email','LIKE','%'.$initialSearch.'%');
});
@ManojKiranA
ManojKiranA / Install.php
Last active November 15, 2019 15:06
Installtion of first Laravel Projects
laravel new projectname &&
composer require laravel/telescope --dev &&
composer require barryvdh/laravel-debugbar --dev &&
php artisan telescope:install &&
php artisan telescope:publish &&
php artisan migrate &&
php artisan telescope:publish &&
composer require spatie/laravel-activitylog &&
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" &&
php artisan migrate &&
@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';

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

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

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

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

}

@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

@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
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 / 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) {