Abstract Local Storage in Vue 3
import useLocalStorage from './useLocalStorage'
const publicKey = useLocalStorage('app-public-key', 'default value')
Get the SQL of a Query Builder without the question marks
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
$this->getBindings()
);
return Str::replaceArray('?', $bindings, $this->toSql());
});
Set up test traits dynamically
$this->afterApplicationCreated(function () {
foreach (class_uses_recursive($this) as $trait) {
if (method_exists($this, $method = 'setUp' . class_basename($trait))) {
call_user_func([$this, $method]);
}
}
});
1 / 1