ekremogul/tena-editor

TenaHaber EditorJS 辅助工具

v1.1 2023-05-18 20:38 UTC

This package is auto-updated.

Last update: 2024-09-18 23:46:43 UTC


README

它是由结合editor-js/editorjs-phpalaminfirdows/laravel-editorjs这两个包创建的。

特别感谢开发者们

安装

您可以通过composer安装此包

composer require ekremogul/tena-editor

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="tena-editor-config"

可选地,您可以使用以下命令发布视图

php artisan vendor:publish --tag="tena-editor-views"

使用方法

use Ekremogul\TenaEditor\TenaEditor;
use App\Models\Post;

$post = Post::find(1);
echo TenaEditor::render($post->body);

// Or use in blade
{!! \Ekremogul\TenaEditor\TenaEditor::render($post->body) !!}

定义一个访问器

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Ekremogul\TenaEditor\TenaEditor;

class Post extends Model
{
    public function getBodyAttribute(){
        return TenaEditor::render($this->attributes['body']);
    }
}

// usage
$post = Post::find(1);
echo $post->body;
// or use in blade
{!! $post->body !!}