Skip to content

Instantly share code, notes, and snippets.

View Mevrael's full-sized avatar

Mev-Rael Mevrael

View GitHub Profile
@Mevrael
Mevrael / WebSocketController.php
Created March 14, 2017 10:40
Laravel + WebSocket (Ratchet/ReactPHP) integration
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Ratchet\WebSocket\Version\RFC6455\Connection;
@Mevrael
Mevrael / mysql_5.7_join_json_column_id.sql
Last active January 11, 2024 16:58
MySQL 5.7 JOIN on JSON column of IDs
# Example for MySQL 5.7 how to use JOIN on 2 tables without junction table using new JSON column type.
# Let say we have 2 tables: posts and users
# Users may like posts
# We store the IDs of users who liked each post in posts.liked column which is a JSON array
# which might have a content like "[1, 2, 5, 10]"
SELECT posts.id AS post_id, users.id AS liked_by_user_id FROM posts JOIN users ON JSON_CONTAINS(posts.liked, CAST(users.id AS CHAR))
<?php namespace App\Core;
use Illuminate\Support\Facades\Lang;
use Pelago\Emogrifier;
class Mailer extends \Illuminate\Mail\Mailer
{
/**
* Send a new message using a view.
*
/*
Native Object.create() does not works with properties if they are objects or arrays.
For example,
var p = {
obj: {
one: 1,
two: 2
}
};
<?php
namespace App\Models\Traits;
use Illuminate\Support\Facades\DB;
use PDO;
trait Iterable
{
public static function iterate(array $columns = [])
@Mevrael
Mevrael / Added new cfg to app.php
Created January 24, 2016 13:39
Example of Laravel localization provider
<?php // after locale
'additional_locales' => ['de'],