Skip to content

Instantly share code, notes, and snippets.

/*
Получение товаров по параметрам фильтров.
В пределах одного родителя между параметрами "или". Между родителями "и".
Модель ProductFilter ('product_id', 'category_id', 'filter_id', 'filter_item_id')
https://github.com/DmitrySkibitsky
*/
/**
* @param $filters // Коллекция с filter_item_id
@vavprog
vavprog / beanstalkd.bat
Created January 15, 2020 05:11 — forked from fhferreira/beanstalkd.bat
Use Beanstalkd into Windows
C:\Users\MyUser\Downloads\beanstalkd-1.4.6-cygwin\bin\beanstalkd.exe -l 127.0.0.1 -p 11300
Попробуйте наше новое меню — с {{ customer.address and customer.address.city == 'Санкт-Петербург' ? 'шавермой' : 'шаурмой' }} ...
@vavprog
vavprog / shortcode.php
Created June 19, 2019 07:17
php shortcode
<?php
$string = 'Hello, {name}. Welcome to {country}';
$patterns = [];
$patterns[0] = '/{name}/';
$patterns[1] = '/{country}/';
$replacements = [];
$replacements[0] = 'Nick';
@vavprog
vavprog / parse_utm.js
Created April 30, 2019 05:28 — forked from hunty/parse_utm.js
Парсит UTM метки и подставляет в скрытые поля
window.onload = function() {
// Parse the URL
function getParameterByName(name) {
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Give the URL parameters variable names
var source = getParameterByName('utm_source');
@vavprog
vavprog / linkify.php
Created March 25, 2019 08:30 — forked from jasny/linkify.php
PHP function to turn all URLs in clickable links
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @param string $mode normal or all
* @return string
*/
@vavprog
vavprog / laravel change public folder
Created February 19, 2019 07:57
laravel change public folder
в методе \App\Providers\AppServiceProviderregister().
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// ...
@vavprog
vavprog / App\Exception\Handler.php
Created November 17, 2018 02:26
Laravel 404 instead Method not Alloved
public function render($request, Exception $exception)
{
if($exception instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException){
return abort('404');
}
return parent::render($request, $exception);
}
@vavprog
vavprog / helpers.php
Created September 7, 2018 16:59 — forked from Valtas/helpers.php
Проверяет идентичность очередности элементов массива A очередности элементов массива Б
if (! function_exists('is_array_same_order')) {
/**
* It checks the order of the array element by orienting itself on the original array.
*
* @param array $same
* @param array $original
*
* @return bool
*/
function is_array_same_order(array $same, array $original)
@vavprog
vavprog / FormRequest.php
Created July 24, 2018 03:20 — forked from Ellrion/FormRequest.php
Laravel FromRequest with methods: prepare (for change and replace input) and sometimes (for add sometimes rules to validator)
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest as BaseFormRequest;
abstract class FormRequest extends BaseFormRequest
{
protected $prepared;