Skip to content

Instantly share code, notes, and snippets.

@rseon
rseon / mailhog.md
Created November 14, 2022 12:08
Mailhog + WampServer + Laravel

Mailhog + WampServer + Laravel

Mailhog

  • Download Mailhog from Github releases
  • Copy and rename the downloaded file to C:\wamp64\bin\mailhog.exe

WampServer

Edit following files :

@rseon
rseon / object2url-test.js
Created September 26, 2022 11:20
Node script to convert object in URL string
const object2url = require('./object2url')
const testData = {
name: "John",
age: 13,
skills: ['games', 'programming', 'reading', 'singing'],
invests: {
education: [120.3, 50.5],
kids: 70,
optical: {
@rseon
rseon / Laravel - Get DB queries.php
Last active May 5, 2022 09:55
Display Laravel queries in PHP files (like the DebugBar but without view)
<?php
/*
* Display Laravel queries in PHP files (like the DebugBar but without view)
*/
/**
* 1. Create the helper
*/
@rseon
rseon / Prestashop_Tips.md
Last active December 21, 2021 16:28
Some tips on Prestashop

AdminPatterns

Pour vous aider dans la conception de vos formulaires ou affichage de configuration de module, il existe un controller caché AdminPatterns qui vous donne tous les champs possibles.

Il est accessible dans l'administration à l'adresse https://website.com/admin_xxxxxx/index.php?controller=AdminPatterns et le controller se trouve dans /controllers/admin/AdminPatternsController.php

Astuce PDF

Gagner du temps lors la personnalisation des fichiers pdf ( factures / livraisons … ) 👉 https://www.h-hennes.fr/blog/2020/07/13/prestashop-gagnez-du-temps-lors-la-personnalisation-des-fichiers-pdf-factures-livraisons/ (ce site est une mine d'or au passage)

@rseon
rseon / deploy.md
Last active November 29, 2021 11:00
Deploy Laravel

Deploy a Laravel project on your server

Create bash file

Only once on your server

Create a deploy.sh file at the root of your project :

#!/usr/bin/env bash
@rseon
rseon / wrapper_json_encode.php
Created June 21, 2021 09:59
A wrapper to safely encode UTF-8 in JSON
<?php
/**
* Wrapper to handle JSON errors and resolve UTF-8 errors
*
* @param mixed
* @param int
* @param int
* @param bool
* @return string|false
@rseon
rseon / cheatsheet.md
Last active December 4, 2022 23:08
Laravel cheatsheet

Laravel cheatsheet

Original Eloquent attribute

When defining an accessor you can access to original value using this to skip mutator :

$model->getRawOriginal('name');

Get model table name

@rseon
rseon / get_by_key_value.php
Last active May 6, 2021 12:30
[PHP] Search value in multidimensional array
<?php
/**
* Search value through multi dimensional array by column key and return first found sub array or corresponding key.
* This method preserves the original array keys.
*
* Multiple returns :
* - The sub-array if value is found
* - A mixed value corresponding to the key (if $onlyKey is set to true)
* - false if an error occured or value is not found
@rseon
rseon / Company.php
Created April 13, 2021 17:10
Laravel QueryBuilder subquery
<?php
namespace App\Models;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
/**
* Table schema is :
@rseon
rseon / readme.md
Created November 6, 2020 11:05
[Laravel] Stored procedure in Debugbar

I needed to call a routine with Laravel but I encountered the MySQL "Packets out of order" error. I've found an answer on this StackOverflow question : $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

I have created a trait that can call a stored procedure and log it in Debugbar :

<?php

namespace App\Models\Traits;