Skip to content

Instantly share code, notes, and snippets.

View cashlion's full-sized avatar
👨‍💻

Nicholas Hoium cashlion

👨‍💻
View GitHub Profile
<?php
use Illuminate\Database\Query\Builder;
Builder::macro('orderByNulls', function ($column, $direction = 'asc', $nulls = 'last', $bindings = []) {
$column = $this->getGrammar()->wrap($column);
$direction = strtolower($direction) === 'asc' ? 'asc' : 'desc';
$nulls = strtolower($nulls) === 'first' ? 'NULLS FIRST' : 'NULLS LAST';
return $this->orderByRaw("$column $direction $nulls", $bindings);
});
@smhmic
smhmic / - README - URL parameter blocklist OR allowlist in GTM.md
Last active May 17, 2022 14:31
URL parameter blocklist/allowlist in GTM.md
@RuGa
RuGa / massInsertOrUpdate.php
Last active April 12, 2024 16:54
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@miguelmota
miguelmota / getDates.js
Last active February 7, 2024 23:43
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
function getDates (startDate, endDate) {
const dates = []
let currentDate = startDate
const addDays = function (days) {
const date = new Date(this.valueOf())
date.setDate(date.getDate() + days)
return date
}
while (currentDate <= endDate) {