use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Casts\IterableItemCast;
use Spatie\LaravelData\Support\Creation\CreationContext;
use Spatie\LaravelData\Support\DataProperty;
class ValueCast implements Cast, IterableItemCast
{
public function __construct(
protected ?string $value = null,
App/Traits/ScopeWhereInSequence.php
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
Laravel Command to generate route endpoints that can be used in typescript fully threeshakable.
GenerateTypescriptRoutes.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
Maak een nieuwe array op basis van een groeisorteeralgoritme, begint bij de oorsprong en groeit vervolgens geleidelijk naar het begin en begin van de array.
Example use case: Loading images for a scroll animation sequence and start loading at a specific percentage
const imagesArray = [
"image1.jpg",
"image2.jpg",
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function searchByKey(array $array, $key) | |
{ | |
if (array_key_exists($key, $array)) return $array[$key]; | |
$recursive = function($chunk) use ($key, &$recursive) { | |
foreach ($chunk as $k => $v) { | |
if ($k === $key) return $chunk[$key]; | |
if (is_array($v) && $found = $recursive($v)) return $found; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('testShadow')) { | |
/** | |
* Magically access a private or protected variable or methods from an instance of a class. | |
* Use this only in UnitTests | |
* | |
* @param mixed $instance Instance of a class | |
* @param string $name Name of the inaccessible variable or method | |
* @return mixed variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/Providers/AppServiceProvider.php | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
public function boot() | |
{ | |
Blueprint::macro('dropIndexIfExists', function ($index) { | |
/** @var Blueprint $this */ |
NewerOlder