norman-huth / muetze-site
此包已被弃用且不再维护。未建议替代包。
始终使用 Laravel 资源
1.0.1
2021-09-19 09:54 UTC
Requires
- php: ^7.4|^8.0
- ext-mbstring: *
- illuminate/console: ^7.0|^8.0
- illuminate/support: ^7.0|^8.0
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')" />