Skip to content

Instantly share code, notes, and snippets.

@IlyaZha
IlyaZha / gist:41dc95c2184db5f65695f1092599a5bb
Last active January 17, 2017 11:54
Creating and dropping foreign keys
/**
* Скрипт создания форейн ключа $foreignKey в таблице $table1 на таблицу $table2.
*
* -Получаем все элементы таблицы1 и таблицы2.
* -Перебираем циклом элементы таблицы1 и проверяем существуют ли они в таблице2.
* -Если элемент в таблице2 не существует, удаляем ссылку на него из таблицы1.
* -Создаем форейн ключ в таблице1.
*/
function validateTableAndCreateForeignKey($table1, $table2, $foreignKey)
{
@IlyaZha
IlyaZha / create_host.sh
Created December 20, 2016 09:49
Create host for laravel-project for Ubuntu.
#!/bin/bash
#Create project folders first. Than run this script
parametr1=$1
projectPath=/home/userName/PhpstormProjects
cp /etc/nginx/example.conf /etc/nginx/conf.d/$parametr1.conf
rpl -iqR example $parametr1 /etc/nginx/conf.d/$parametr1.conf
sed -i -e '1 s/^/127.0.0.1 '$parametr1'.local\n/;' /etc/hosts
service nginx restart
chown www-data $projectPath/$parametr1/bootstrap/cache/
@IlyaZha
IlyaZha / gist:a72ea944f1fb7daebbee9bbcefb97399
Last active December 13, 2016 12:00 — forked from drakakisgeo/gist:3bba2a2600b4c554f836
Auto trim all input [Laravel 5]
// Step 1. Create this class in the middleware folder (/app/Http/Middleware).
<?php
namespace App\Http\Middleware;
use Closure;
class BeforeAutoTrimmer {