Skip to content

Instantly share code, notes, and snippets.

@sahibalejandro
sahibalejandro / deploy.sh
Last active January 8, 2024 17:48
Deploy script for Laravel projects.
# Shutdown the laravel app
php artisan down
# Install new composer packages
composer install --no-dev --prefer-dist
# Cache boost configuration and routes
php artisan cache:clear
php artisan config:cache
php artisan route:cache
@zofe
zofe / PaginateTrait.php
Last active March 19, 2019 20:30
switch laravel 5 pagination from QueryString To URI, using simple traits on models
<?php
/**
* usage in a controlller:
* public function index($page=1) {
* $users = User::paginateUri(5, $page, $links);
* return view('users', compact('users','links'));
* }
* it also support variable number of parameters,
* routes must be defined using {page} or {page?} placeholders
@ofirski
ofirski / merge_mongo_collections.js
Last active March 15, 2017 13:32
Merge MongoDB collections
/*******************************************************************************
* Merges matching documents from source collection into desination collection
* Usage:
* mergeCollections("srcCollName", "destCollName", null, ["f1","f3"])
* mergeCollections("srcCollName", "destCollName", {xy:"z"}, ["f1","f4"])
********************************************************************************/
function mergeCollections(sourceCollection, destCollection, sourceQuery, setFields) {
var nMatched = 0;
var nModified = 0;
sourceQuery = sourceQuery || {}