Skip to content

Instantly share code, notes, and snippets.

@Muetze42
Muetze42 / 0_Extend & set up (new) Laravel App.md
Last active April 10, 2022 20:34
Extend & set up (new) Laravel App

Settings, Commands etc....

@Muetze42
Muetze42 / Resource.php
Last active April 9, 2022 17:19
Laravel Nova (4) Resource with Optional sorting and filter options
<?php
namespace App\Nova;
use Illuminate\Database\Eloquent\Builder;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource as NovaResource;
use Laravel\Scout\Builder as ScoutBuilder;
abstract class Resource extends NovaResource
@Muetze42
Muetze42 / CustomPathGenerator.php
Last active September 25, 2022 17:09
Custom Path Generator for „Spatie Media Library“
<?php
namespace App\Support\Spatie;
use Illuminate\Support\Str;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
class CustomPathGenerator implements PathGenerator
{
@Muetze42
Muetze42 / style.scss
Last active March 9, 2022 08:43
Font Awesome Badge before example
$font-awesome: 'Font Awesome 5 Pro';
$color-alert: #e74b4b;
a {
color: $color-alert !important;
padding-left: 1.65rem;
&:before {
position: absolute;
width: 0.9rem;
@Muetze42
Muetze42 / auth.json
Last active January 21, 2022 08:37
Your GitHub OAuth token for github.com contains invalid characters on composer install
// `nano ~/.composer/auth.json`
//
// Basic- and OAuth:
{
"http-basic": {
"github.com": {
"username": "[GITHUB-USERNAME]",
"password": "ghp_[PERSONAL-TOKEN]"
},
"nova.laravel.com": {
@Muetze42
Muetze42 / DownCommand.php
Created December 31, 2021 20:25
Laravel: Default View For Maintenance Mode
<?php
namespace App\Console\Commands;
use Illuminate\Foundation\Console\DownCommand as Command;
use Illuminate\Foundation\Exceptions\RegisterErrorViewPaths;
class DownCommand extends Command
{
/**
@Muetze42
Muetze42 / functions.php
Last active December 21, 2021 09:04
WordPress: HTML lang in ISO 639-1 Language Codes
<?php
add_filter('language_attributes', function () {
return 'lang="'.explode('-', get_bloginfo('language'))[0].'"';
}, 10, 2);
@Muetze42
Muetze42 / .htaccess
Created December 10, 2021 07:48
htaccess Whitelisting
#Allow w3c validator
Allow from 128.30.52.73
Allow from 128.30.52.96
Allow from .w3.org
#Allow PayPal
Allow from 151.101.129.21
Allow from .paypal.com
@Muetze42
Muetze42 / functions.php
Last active March 21, 2022 12:51
WordPress: Set default attachment filter for post/product image
<?php
add_action('admin_footer-post-new.php', 'wp_admin_default_media_attachment_filter');
add_action('admin_footer-post.php', 'wp_admin_default_media_attachment_filter');
function wp_admin_default_media_attachment_filter()
{
?>
<script type="text/javascript">
jQuery(document).on("DOMNodeInserted", function () {
jQuery('select.attachment-filters [value="uploaded"]').attr('selected', true).parent().trigger('change');
@Muetze42
Muetze42 / functions.php
Last active March 29, 2022 20:52
WordPress WooCommerce: Add Revisions For Products
<?php
add_filter( 'woocommerce_register_post_type_product', 'wc_add_revision_support' );
function wc_add_revision_support( $args ) {
$args['supports'][] = 'revisions';
return $args;
}