1. Go to this page and download the library: Download te7a-houdini/laravel-trix library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
te7a-houdini / laravel-trix example snippets
Post::create(request()->all());
//storing must follow this convention (model lowered class name)-trixFields
Post::create([
'post-trixFields' => request('post-trixFields'),
]);
<!-- inside view blade file -->
@trix($post, 'content')
{!! $post->trix('content') !!} //must use HasTrixRichText trait in order for $model->trix() method work
{!! app('laravel-trix')->make($post, 'content') !!}
<!-- inside view blade file -->
{!! $post->trixRender('content') !!} //must use HasTrixRichText trait in order for $model->trixRender() method work
Post::create(request()->all());
//storing must follow this convention (model lowered class name)-trixFields
//and for attachment must follow attachment-(model lowered class name)-trixFields
Post::create([
'post-trixFields' => request('post-trixFields'),
'attachment-post-trixFields' => request('attachment-post-trixFields')
]);
class Post extends Model
{
use HasTrixRichText;
protected $guarded = [];
protected static function boot()
{
parent::boot();
static::deleted(function ($post) {
$post->trixRichText->each->delete();
$post->trixAttachments->each->purge();
});
}
}