Skip to content

Instantly share code, notes, and snippets.

View mehranhadidi's full-sized avatar
🚀

Mehran Hadidi mehranhadidi

🚀
  • Solvd
View GitHub Profile
@mehranhadidi
mehranhadidi / compat_l5.php
Created December 6, 2016 08:24 — forked from vluzrmos/compat_l5.php
Lumen L5 compatibility helpers. That file should be added on root path of your project... and added to your composer.json
<?php
if(!function_exists('config_path'))
{
/**
* Return the path to config files
* @param null $path
* @return string
*/
function config_path($path=null)
# How to show current git branch name
# Add following lines to your ~/.bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
# ----------------------------------------------------------------------------------------------
// eager load in laravel new way
$post = Post::find(1);
$post->load('comments.owner'); // will load the post + comments (relationship) + owner (relationship)
return $post;
@mehranhadidi
mehranhadidi / sql.txt
Last active August 23, 2016 05:04
Log SQL queries in laravel
// should add to AppServiceProvider@boot
\DB::listen(function ($query) { \Log::info($query->sql, $query->bindings); });
// should add to routes.php
Event::listen('illuminate.query', function($query)
{
var_dump($query);
});