norman-huth/muetze-site

This package is abandoned and no longer maintained. No replacement package was suggested.

Always used Laravel resources

Installs: 52

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

Type:laravel-package

1.0.1 2021-09-19 09:54 UTC

This package is auto-updated.

Last update: 2021-11-19 10:09:23 UTC


README

This package includes what I often miss in Laravel and newer stubs.

Install

composer require norman-huth/muetze-site

Usage

Commands

Create Pivot Table

This command creates a migration for a many-to-many relationship between 2 models.
The 2 models of the relationship must be specified in the command.

php artisan make:migration:pivot User Role

Option if one or both primary column names are not id

php artisan make:migration:pivot User Role --id1=uui --id2=foo_bar

make:bundle Command

Create a model with a migration and policy
(The default can be adjusted in config.)

php artisan make:bundle Foo

Create with options to create resources disabled by config anyway.

// {--n : create with nova resource}
// {--m : create with migration}
// {--p : create with policy}
// {--r : create with resource}
// {--c : create with controller}
// {--a : create with api controller}
php artisan make:bundle Foo --n --m --p --r
Change the default details of the make:bundle command
php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="config"

Default:

    'make-bundle' => [
        'nova-resource' => false,
        'migration'      => true,
        'policy'         => true,
        'resource'       => true,
        'controller'     => false,
        'api-controller' => false,

        'namespaces' => [
            'controller'     => 'Web/',
            'api-controller' => 'Api/',
        ],
    ],

Traits

Encrypt Attributes

The attributes always stored encrypted in the database, but output decrypted.
For these attributes simply create a column text (nullable) and specify in the array encrypts.

<?php

namespace App\Models;

use NormanHuth\Muetze\Traits\EncryptsAttributes;
use Illuminate\Database\Eloquent\Model;

class UserData extends Model
{
    use EncryptsAttributes;

    /**
     * The attributes that are encrypted.
     *
     * @var array
     */
    protected array $encrypts = [
        'access_token',
        'address',
    ];
}

Publish

Newer Laravel Stubs

No more problem with duplicate class names

php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="laravel-stubs"

Newer Laravel Nova Stubs

php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="nova-stubs"

Additional Language File(s)

For example, to keep the Laravel translations in the original state and in case of an update they can be renewed without merge.

php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="translations"

Markdown Blade Component

Parse markdown

<x-site-markdown>
    {{ $markdown }}
</x-site-markdown>

Parse markdown without stripping whitespace (or other characters) from the beginning in each line of a string

<x-site-markdown :trim="false">
    {{ $markdown }}
</x-site-markdown>

Parse Markdown file

<x-site-markdown :file="$markdown" />

<!-- Don't forget the single quotes (:file) -->
<x-site-markdown :trim="false" :file="'/path/to/file.md'" />

<x-site-markdown :file="resource_path('views/markdowns/content.md')" />

Helper Functions

Helpers/functions.php