Skip to content

Instantly share code, notes, and snippets.

View ahmetbedir's full-sized avatar
🎯
Focusing

Ahmet Bedir ahmetbedir

🎯
Focusing
View GitHub Profile
@ahmetbedir
ahmetbedir / toSqlWithBindings.php
Last active January 14, 2021 17:29
Laravel toSqlWithBindings
<?php
use Illuminate\Database\Eloquent\Builder
Builder::macro('toSqlWithBindings', function(){
$bindings = array_map(function($value){
return is_numeric($value) ? $value : "'{$value}'";
}, $this->getBindings());
return Str::replaceArray('?', $bindings, $this->toSql());
@ahmetbedir
ahmetbedir / setDocumentRootPublic.sh
Last active July 13, 2020 23:53
cPanel Document Root append public folder name by domain script for laravel
#!/bin/sh
# Update the "documentroot" value to the new path in the following files
sed -i -e 's/public_html/public_html\/public/g' /var/cpanel/userdata/$1/$2
# Update the "documentroot" value to the new path in the following files
sed -i -e 's/public_html/public_html\/public/g' /var/cpanel/userdata/$1/$2_SSL
# Remove the existing cache files
rm -f /var/cpanel/userdata/$1/$2.cache
@ahmetbedir
ahmetbedir / now.php
Last active April 22, 2020 17:16
PHP Carbon Helper (Anonymous class)
<?php
if (!function_exists('now')) {
function now()
{
return new class()
{
protected $now;
protected $defaultFormat = 'd.m.Y H:i:s';