Skip to content

Instantly share code, notes, and snippets.

View Rapkalin's full-sized avatar
🏠
Working from home

Raphael Rapkalin

🏠
Working from home
View GitHub Profile
@Rapkalin
Rapkalin / previewSql.php
Last active August 6, 2023 19:15
Preview SQL query with Laravel
<?php
Function previewSql()
{
$users = User::where(‘id’, 0);
$users->union(User::where(‘id’, 1));
$users->union(User::where(‘id’, 2));
$users->union(User::where(‘id’, 3));
// Preview sql statement using getBindings() and toSql() builder methods
@Rapkalin
Rapkalin / PHP - Move given value to the end of an array
Last active October 21, 2022 14:46
PHP function to move a searched value to the end of an array
public static function moveValueToTheEnd(array $array, $searchedValue) : array
{
dump('initial array', $array);
$j = 0;
for ($i = 0; $i < (count($array)); $i++) {
if ($array[$i] === $searchedValue && isset($array[$i + 1])) {
$array[$i] = $array[$i + 1];
$array[$i + 1] = $searchedValue;