Skip to content

Instantly share code, notes, and snippets.

View lukeraymonddowning's full-sized avatar

Luke Downing lukeraymonddowning

View GitHub Profile
@lukeraymonddowning
lukeraymonddowning / app\Foo.php
Created August 25, 2022 17:01
Created by Pest Playground
<?php
namespace App;
class Foo
{
}
<?php
namespace App;
class Str
{
public static function lower($subject)
{
return strtolower($subject);
}
export default defineConfig({
plugins: [
laravel(['resources/js/app.js']),
{
name: 'ziggy',
enforce: 'post',
handleHotUpdate({ server, file }) {
if (file.includes('/routes/') && file.endsWith('.php')) {
exec('php artisan ziggy:generate', (error, stdout) => error === null && console.log(` > Ziggy routes generated!`))
}
@lukeraymonddowning
lukeraymonddowning / example-stub.php.stub
Created June 1, 2021 16:11
Example of more complex Stubble usage
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use App\Models\{{ model }};
use App\Http\Requests\{{ model | basename }}\{{ store_request }};
use App\Http\Requests\{{ model | basename }}\{{ update_request }};
@lukeraymonddowning
lukeraymonddowning / Macro.php
Created March 26, 2021 09:36
Tailwind specificity helper for Laravel Blade
ComponentAttributeBag::macro('fallback', function($classes) {
$fallbacks = Collection::wrap($classes)
->mapWithKeys(fn($partial, $fallback) => is_int($fallback) ? [$partial => Str::of($partial)->before("-")->when(Str::contains("-", $partial), fn($string) => $string->append('-'))->__toString()] : [$fallback => $partial])
->toArray();
return $this->class($fallbacks);
});