Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nickclasener
nickclasener / opendb.sh
Created September 19, 2020 05:51 — forked from AlexVanderbist/opendb.sh
`opendb` command - opens the database for a Laravel app in your GUI
opendb () {
[ ! -f .env ] && { echo "No .env file found."; exit 1; }
DB_CONNECTION=$(grep DB_CONNECTION .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_HOST=$(grep DB_HOST .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PORT=$(grep DB_PORT .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_DATABASE=$(grep DB_DATABASE .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_USERNAME=$(grep DB_USERNAME .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PASSWORD=$(grep DB_PASSWORD .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
@nickclasener
nickclasener / .php_cs.dist
Last active October 2, 2019 00:46 — forked from davidhemphill/.php_cs.laravel.php
PHP CS Fixer - Laravel Ruleset
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
@nickclasener
nickclasener / Notification.php
Last active September 30, 2019 20:27
Adds Godlike quake sound after tests passed.
<!-- Location vendor/spatie/phpunit-watcher/src/Notification.php -->
<?php
namespace Spatie\PhpUnitWatcher;
use Joli\JoliNotif\NotifierFactory;
use Joli\JoliNotif\Notification as JoliNotification;
class Notification
{
// Add this to the "boot()" method of your "AppServiceProvider"
<?php
\Illuminate\Database\Eloquent\Builder::macro('search', function ($name, $search) {
return $this->where($name, 'LIKE', $search ? '%'.$search.'%' : '');
});
public static function boot()
{
parent::boot();
static::creating(function($model) {
$model->slug = str_slug($model->ToBeSlugified);
$latestSlug =
static::whereRaw("slug = '$model->slug' or slug LIKE '$model->slug-%'")
->latest('id')