Skip to content

Instantly share code, notes, and snippets.

@devig
devig / example.php
Last active January 5, 2020 22:47
Laravel Datatables
<?php
//...
public function productsTable() {
$query = \DB::table('products')->leftJoin('brands', 'brands.id', '=', 'products.brand_id')
->select([\DB::raw("CONCAT(products.name, ' ', products.code) as full_name"),'products.slug','price','brands.name as brand','products.id']);
return datatables($query)
->addColumn('action', function ($row) {
return '<a href="'.$row->id.'" class="btn btn-sm btn-primary">Edit'.$row->id.'</a>';
@devig
devig / helper.php
Last active February 29, 2020 12:38 — forked from Ellrion/helper.php
Посмотреть запрос с параметрами
<?php
if (! function_exists('dqd')) {
/**
* Dump info about query in builder and end the script.
*
* @param $query
* @param bool $short
*/
function dqd($query, $short = false)
@devig
devig / ModelJoinTrait.php
Created February 29, 2020 13:08 — forked from pionl/ModelJoinTrait.php
Model join trait with Automatic Join on Laravel 5 Eloquent Models with relations setup. With automatic filling relation object if detected
<?php
namespace Pion\Traits\Models;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Str;
/**
* Class ModelJoinTrait
*
* Trait to create model join for scope with detection of model in the attributes.
@devig
devig / Dockerfile
Created March 15, 2020 05:27
php5.6-apache-ioncube for opencart
FROM php:5.6.40-apache
RUN a2enmod rewrite
RUN set -xe \
&& apt-get update \
&& apt-get install -y libxml2-dev libpng-dev libjpeg-dev libc-client-dev libkrb5-dev curl \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-configure imap --with-imap-ssl --with-kerberos \
@devig
devig / index.js
Last active May 19, 2020 13:49
MYSQL adminer
var express = require('express');
var app = express();
var mysql = require('mysql');
//var nodeadmin = require(__dirname + '/../middleware/index.js');
var nodeadmin = require('nodeadmin'); //https://github.com/nodeadmin/nodeadmin
//app.use(nodeadmin(app));
app.use(nodeadmin(app, process.env.PORT || 4040));
app.use('/', function(req, res, next) {
@devig
devig / site.conf
Last active March 26, 2021 20:47
Nginx
# $http_x_firebase
log_format postdata escape=json '$remote_addr $remote_user [$time_local] $request_time $request $status $body_bytes_sent $http_referer "$http_user_agent"'
' $request_body';
server {
listen 443 ssl http2;
server_name site.com;
access_log "/var/log/nginx/site.com_ssl-access.log" postdata;
error_log "/var/log/nginx/site.com_ssl-error.log" warn;
@devig
devig / table.html
Last active July 6, 2020 16:50
Table example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<style type="text/css">
TABLE {
width: 300px; /* Ширина таблицы */
@devig
devig / cors.php
Created July 7, 2020 04:15
Check CORS
<?php
header('Accept : application/json');
header('Access-Control-Allow-Origin : *');
header('Access-Control-Allow-Methods : POST,GET,OPTIONS,PUT,DELETE');
header('X-Requested-With : XMLHttpRequest');
header('Access-Control-Allow-Headers : Content-Type,Authorization');
//https://cors-anywhere.herokuapp.com/
if (!empty($_SERVER["REQUEST_METHOD"]) && $_SERVER['REQUEST_METHOD']=='OPTIONS') {
header("HTTP/1.1 204 NO CONTENT");
@devig
devig / tree.php
Last active July 23, 2020 13:57
jiaxincui/closure-table
<?php
$menu = \App\Menu::find(1);
$menu->getDescendantsAndSelf();
$menu = \App\Menu::find(3);
$menu->getAncestorsAndSelf();
$menu = \App\Menu::find(1);
dd($menu->getTree());
@devig
devig / main.go
Last active January 15, 2022 11:45
Gorose ORM
package main
import (
"fmt"
"os"
"github.com/gohouse/gorose/v2"
_ "github.com/go-sql-driver/mysql"
)
var err error