litstack/meta 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

litstack/meta

Composer 安装命令:

composer require litstack/meta

包简介

README 文档

README

Edit default meta-fields inside your crud-models and forms and receive them in your blade templates.

Installation

The package can be installed via composer and will autoregister.

composer require litstack/meta

You can now publish and migrate the migration for your meta model:

php artisan vendor:publish --provider="Litstack\Meta\MetaServiceProvider" --tag=migrations
php artisan migrate

Usage

Start by perparing your Crud-Model by using the HasMeta Trait and implement the metaable Contract:

use Litstack\Meta\Metaable;
use Litstack\Meta\Traits\HasMeta;

class Post extends Model implements Metaable
{
    use HasMeta;
}

In order to display the form in litstack edit your model-config:

public function show() 
{
    $page->card(function($form) {
        $form->seo();
    });
}
        

To display the meta-fields in your template, simply use the <x-lit-meta /> component and pass it the metaFields of your model.

@extends('app')

@section('meta')
    <x-lit-meta :for="$post" />
@endsection

And in your main template:

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    @yield('meta')
</head>

Default Values / Customizing / Overriding

If you want to use meta attributes directly from model attributes you can specify them in metaAttributes in your config. You may as well override the meta methods like metaAuthor to return dynamic meta attributes:

class Post extends Model implements Metaable
{
    use HasMeta;

    protected $metaAttributes = [
        'author' => 'author.name',
        'image'  => 'header_image',
    ];

    public function getHeaderImageAttribute()
    {
        // ...
    }

    public function metaTitle(): ?string
    {
        // Return a prefix:
        return "Awesome Blog: " . parent::metaTitle();
    }
}

You may set default attributes by setting defaultMetaAttributes or add a method defaultMeta... method:

class Post extends Model implements Metaable
{
    use HasMeta;

    protected $defaultMetaAttribute = [
        'description' => 'description',
    ];

    public function defaultMetaTitle()
    {

    }
}

统计信息

  • 总下载量: 5.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固