Skip to content

Instantly share code, notes, and snippets.

Blade::extend(function ($view) {
return preg_replace(
'/{{(\'|")(.*)(\'|")}}/',
'<?php echo e(trans($1$2$1)); ?>',
$view
);
});
// And you should be able to do tho this on your Blade templates
@antonioribeiro
antonioribeiro / tables.php
Created October 25, 2016 13:56
Get all tables from database on Laravel
function tables($connection = null)
{
return collect(json_decode(json_encode(DB::connection($connection)->select(get_show_tables_query($connection))), true))
->map(function ($item) {
return array_values($item)[0];
});
}
function get_show_tables_query($connection = null)
{
@antonioribeiro
antonioribeiro / id.md
Last active September 13, 2016 01:47

Here's a Spark migration example, using UUID as primary key:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSubscriptionsTable extends Migration
{

/**

Verifying that +antonioribeiro is my blockchain ID. https://onename.com/antonioribeiro

###Form Request (Validation)

class Update extends FormRequest {

	public function rules()
	{
		return [
			... whatever
 ];

Copy the whole folder to to a subfolder on your project and add a reference to in in your package composer.json. I had to do this with jasonlewis/resource-watcher, so this is now my package autoload section:

"autoload": {
    "psr-4": {
        "PragmaRX\\Ci\\": "src/"
    },
    "psr-0": {
        "JasonLewis\\ResourceWatcher": "src/Support/jasonlewis/resource-watcher/src"
    }

},

# Tail Laravel and Webserver (NGINX & Apache 2) log files
# Compatible with Laravel 4 & 5
#
alias tl="ls -d /var/log/nginx/* /var/log/apache2/* storage/logs/* app/storage/logs/* storage/laravel.log | grep -v 'gz$' | grep -v '1$' | xargs tail -f"

#####Let's say someone has this class

<?php 

// 

class Load {

 public static function load($file)

##What’s wrong with Annotations in PHP

####App logic and structure expressed in COMMENTS, which is enchanting for beginners (Look’ma no PHP, magic!), but terrible for real development. We are developers, we write and debug code. But Annotations is a COMMENTS parser. I really don’t want to debug any string based parser instead of my code. COMMENTS should be just, well..., comments!, not a source of truth!


People may see a really big difference between DocBlocks and comments, but as a matter of fact they are comments, block comments. If they were not supposed to be comments, then they should have completely changed the delimiters, which, I know could be a problem to the compiler...

Block comments in PHP are C & C++ block comments:

###Edit this file

/etc/nginx/nginx.conf

###Add this line anywhere inside the http { } block:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

###Go to your Forge panel and restart Nginx