Skip to content

Instantly share code, notes, and snippets.

View AnandPilania's full-sized avatar
🎖️
Working from home

Anand Pilania AnandPilania

🎖️
Working from home
View GitHub Profile
@AnandPilania
AnandPilania / PolicyGeneratorCommand.php
Created February 13, 2021 16:03
Generate Policies & Models (if not created yet) from AuthServiceProvider's mapped Policies.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider;
use Illuminate\Support\Str;
class PolicyGenerateCommand extends Command
{
@AnandPilania
AnandPilania / InsertLineTrait.php
Created February 13, 2021 16:08
Extends Laravel's default `model:make` command, than support Nova Resource (if using Laravel Nova); create Policy & add mapping to `AuthServiceProvider`
<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait InsertLineTrait
{
public function insertLineAfter($path, $needle, $replace)
{
@AnandPilania
AnandPilania / PolicyMakeCommand.php
Created February 13, 2021 16:12
Extends Laravel's default `make:policy` command that auto add related mapping to `AuthServiceProvider`
<?php
namespace App\Console\Commands;
use App\Traits\InsertLineTrait; // https://gist.github.com/AnandPilania/da4ddbc407b97c9ce89ff130a5dc9c1e#file-insertlinetrait-php
use Illuminate\Foundation\Console\PolicyMakeCommand as Command;
use Symfony\Component\Console\Input\InputOption;
class PolicyMakeCommand extends Command
{
@AnandPilania
AnandPilania / TraitMakeCommand.php
Created February 13, 2021 16:15
Easily create your own scaffold via Laravel Command; example: generate `Traits`
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
class TraitMakeCommand extends GeneratorCommand
{
protected $name = 'make:trait';
@AnandPilania
AnandPilania / Socialite.php
Last active July 10, 2023 14:26
LARAVEL: Social Auth via Socialite with Breeze
<?php
namespace App\Models;
use App\Traits\BelongsToUser;
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Socialite extends Model
@AnandPilania
AnandPilania / phpstorm_shell.bat
Created March 19, 2021 11:32
Add `Open with PHPStorm` to context menu
@echo off
SET PhpStormPath=PATH_TO_PHPSTORM_EXE{EX:DIR\PhpStorm\bin\phpstorm64.exe}
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
echo Adding within a folder entries
@AnandPilania
AnandPilania / intellij_shell.bat
Created March 19, 2021 11:40
`Open with IntelliJ` to context menu
SET IntelliJPath=INTELLIJ_EXE_PATH{ex DIR\bin\idea64.exe}
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\IntelliJ" /t REG_SZ /v "" /d "Open in IntelliJ" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\IntelliJ" /t REG_EXPAND_SZ /v "Icon" /d "%IntelliJPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\IntelliJ\command" /t REG_SZ /v "" /d "%IntelliJPath% \"%%1\"" /f
echo Adding within a folder entries
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\IntelliJ" /t REG_SZ /v "" /d "Open in IntelliJ" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\IntelliJ" /t REG_EXPAND_SZ /v "Icon" /d "%IntelliJPath%,0" /f
@AnandPilania
AnandPilania / SharedHostingCompatibilityCommand.php
Last active January 11, 2023 16:56
Laravel Artisan Command for Shared-Hosting Compatibility (support HTTPS option)
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
class SharedHostingCompatibilityCommand extends Command
@AnandPilania
AnandPilania / SVN.php
Last active November 9, 2022 07:51
Get project (local) SVN details in Laravel
<?php
namespace App\Support;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Schema;
class SVN
{
protected $connection;
@AnandPilania
AnandPilania / RB-precommit.php
Created November 18, 2022 08:42 — forked from mbaker3/RB-precommit.php
SVN pre-commit intergration with Review Board
#!/usr/bin/php
<?php
/**
* Pre-commit Subversion script.
*
* Forces the commit message to have a line like
* review: 42
* and checks that the review has received a Ship It! from
* a peer.
* @author Omni Adams <omni@digitaldarkness.com>