Skip to content

Instantly share code, notes, and snippets.

@lorisleiva
lorisleiva / toSqlWithBindings.php
Last active November 15, 2023 08:54
A little macro to get the SQL from a query builder without the annoying "?".
<?php
use Illuminate\Database\Eloquent\Builder;
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
$this->getBindings()
);
@JFossey
JFossey / ExampleFacade.php
Last active October 12, 2021 15:43
Application / DOMAIN Packages: How to separate code (PHP Composer + Laravel)
<?php
declare(strict_types=1);
namespace Example;
// Framework
use Illuminate\Support\Facades\Facade;
/**