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;
trait FullTextSearch
{
/**
* Replaces spaces with full text search wildcards
*
* @param string $term
@ManojKiranA
ManojKiranA / MatchableTrait.php
Created July 30, 2020 03:54 — forked from zzgael/MatchableTrait.php
Laravel 4+ very basic search Trait that you can add on any model
<?php
use Illuminate\Database\Query\Builder;
/**
* Trait MatchableTrait
* Author : Gael Debost
* Add a very basic match method to an Eloquent Model. Based on a SQL MATCH
* You need FULL TEXT Indexes in order to match fields. Somes rules :
@ManojKiranA
ManojKiranA / awesm.md
Created July 30, 2020 03:52 — forked from matula/awesm.md
Awesome PHP stuff in one Gist
@ManojKiranA
ManojKiranA / README.md
Created July 30, 2020 03:47 — forked from ulhaq/README.md
Simple Laravel Database Search

This is a simple trait for database searching.

Model

Our model should of course use the Searchable trait. Likewise, we have to declare the model attributes which shall be searchable.

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Traits\Searchable;
@ManojKiranA
ManojKiranA / TagTrait.php
Created July 30, 2020 03:45 — forked from saniyathossain/TagTrait.php
Trait for A Virtual Field to Laravel Model Collection
<?php
namespace App\Eloquents\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Str;
use ReflectionClass;
/**
* Generates prefixed column along with padded specific model attribute (e.g. model table primary key attribute)
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Pagination\UrlWindow;
use Illuminate\Support\Arr;
use Barryvdh\Debugbar\Facade as DebugbarFacade;
use Illuminate\Container\Container;
use Illuminate\Contracts\Pagination\LengthAwarePaginator as LengthAwarePaginatorContract;
@ManojKiranA
ManojKiranA / DataStructureGenerator.php
Created July 20, 2020 09:01 — forked from saeedvir/DataStructureGenerator.php
Generate data in key/value structure / For ex: for admin panel dashboard
<?php
/**
*
* @author Saeedvir [
* 'email' => '[email protected]',
* 'telegram' => 'https://t.me/PhpWebDeveloper'
* ]
* @usage :
$dataGenerator = new DataStructureGenerator('data', true,true);
$dataGenerator->setData('users', 8);
<?php /** @var Illuminate\View\ComponentAttributeBag $attributes */ ?>
<?php /** @var Illuminate\Support\HtmlString $slot */ ?>
<?php /** @var int $delay */ ?>
<?php /** @var string $callback */ ?>
<div x-data="abortableButton()" x-init="delay = {{ $delay ?? 5000 }}; callback = () => { {{ $callback }} };" class="w-1/2">
<template x-if="!clicked">
<button
type="button"
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded w-full"
@ManojKiranA
ManojKiranA / BaseModel.php
Last active July 2, 2020 14:13
Useful Laravel Function, Classes, Traits, Mixins, Macros and Much More laravel Related stuff
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use RecursiveArrayIterator;
use RecursiveIteratorIterator;
@ManojKiranA
ManojKiranA / keep-csrf-alive.blade.php
Created June 21, 2020 05:15 — forked from tanthammar/keep-csrf-alive.blade.php
Keep livewire form session alive (419)
<script data-turbolinks-eval=false>
function updateToken() {
fetch('/update-csrf')
.then(response => response.text())
.then(csrf => {
document.head.querySelector('meta[name="csrf-token"]').setAttribute('content', csrf)
})
}
setInterval(updateToken, 1000 * 60 * 5)
</script>