norman-huth/muetze-site

此包已被弃用且不再维护。未建议替代包。

始终使用 Laravel 资源

安装: 52

依赖: 0

建议者: 0

安全: 0

星标: 3

关注者: 1

分叉: 0

开放问题: 0

类型: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

此包包括我在 Laravel 中经常缺少的以及更新的模板。

安装

composer require norman-huth/muetze-site

用法

命令

创建交叉表

此命令为两个模型之间的多对多关系创建迁移。
必须在命令中指定关系的两个模型。

php artisan make:migration:pivot User Role

如果主键列名称不是 id 的选项

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

make:bundle 命令

创建带有迁移和策略的模型
(默认值可以在配置中调整。)

php artisan make:bundle Foo

即使配置禁用,也可以使用选项创建资源。

// {--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
修改 make:bundle 命令的默认详情
php artisan vendor:publish --provider="NormanHuth\Muetze\SiteServiceProvider" --tag="config"

默认值

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

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

特性

加密属性

属性始终以加密形式存储在数据库中,但输出时解密。
对于这些属性,只需创建一个文本列(可为空)并指定在数组中加密。

<?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',
    ];
}

发布

更新的 Laravel 模板

不再存在重复类名的问题

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

更新的 Laravel Nova 模板

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

附加语言文件

例如,为了保持 Laravel 翻译的原状,并在更新时无需合并即可更新。

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

Markdown Blade 组件

解析 markdown

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

解析字符串中每一行的 markdown,不删除(或其它字符)空格(或其它字符)

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

解析 markdown 文件

<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')" />

辅助函数

Helpers/functions.php