{"id":13828119,"url":"https://github.com/amaelftah/laravel-trix","last_synced_at":"2026-01-11T16:40:26.898Z","repository":{"id":43885334,"uuid":"217703400","full_name":"amaelftah/laravel-trix","owner":"amaelftah","description":"Configurable Basecamp Trix Editor (WYSIWYG) delivered to your laravel application","archived":false,"fork":false,"pushed_at":"2025-02-18T17:14:31.000Z","size":52,"stargazers_count":541,"open_issues_count":33,"forks_count":52,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-02T22:10:03.785Z","etag":null,"topics":["laravel","php","trix","trix-editor","wysiwyg"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amaelftah.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-26T12:10:06.000Z","updated_at":"2025-05-30T18:33:59.000Z","dependencies_parsed_at":"2024-06-18T13:42:08.709Z","dependency_job_id":null,"html_url":"https://github.com/amaelftah/laravel-trix","commit_stats":{"total_commits":25,"total_committers":12,"mean_commits":"2.0833333333333335","dds":"0.43999999999999995","last_synced_commit":"ada6aaf662b363638e64306d981a30356fbaccfa"},"previous_names":["te7a-houdini/laravel-trix"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/amaelftah/laravel-trix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaelftah%2Flaravel-trix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaelftah%2Flaravel-trix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaelftah%2Flaravel-trix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaelftah%2Flaravel-trix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amaelftah","download_url":"https://codeload.github.com/amaelftah/laravel-trix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaelftah%2Flaravel-trix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264399167,"owners_count":23602048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","trix","trix-editor","wysiwyg"],"created_at":"2024-08-04T09:02:32.950Z","updated_at":"2026-01-11T16:40:26.859Z","avatar_url":"https://github.com/amaelftah.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg height=\"400px\" src=\"logo.svg\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/Te7a-Houdini/laravel-trix/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/Te7a-Houdini/laravel-trix.svg?style=flat-square\" alt=\"Releases\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/Te7a-Houdini/laravel-trix\"\u003e\u003cimg src=\"https://img.shields.io/travis/Te7a-Houdini/laravel-trix/master.svg?style=flat-square\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.styleci.io/repos/217703400\"\u003e\u003cimg src=\"https://github.styleci.io/repos/217703400/shield\" alt=\"StyleCI\"\u003e\u003c/a\u003e\n\u003ca href=\"https://scrutinizer-ci.com/g/Te7a-Houdini/laravel-trix/?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/scrutinizer/g/Te7a-Houdini/laravel-trix.svg?style=flat-square\" alt=\"Code Quality\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Te7a-Houdini/laravel-trix/blob/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/github/license/Te7a-Houdini/laravel-trix.svg?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/te7a-houdini/laravel-trix\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/Te7a-Houdini/laravel-trix.svg?style=flat-square\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n## Configurable [Basecamp Trix Editor](https://trix-editor.org/) delivered to your laravel application\n\ninspired by [Rails Action Text](https://edgeguides.rubyonrails.org/action_text_overview.html)\n\n\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Using @trix($model, $field, $config = [])](#using-@trix($model,-$field,-$config-=-[]))\n  * [Storing Rich Text Fields](#storing-rich-text-fields)\n  * [Render Trix For Existing Model](#render-trix-for-existing-model)\n  * [Storing Attachment](#storing-attachment)\n  * [Changing Storage Disk](#changing-storage-disk)\n  * [Configuration Table](#configuration-table)\n* [Testing](#testing)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require te7a-houdini/laravel-trix\n```\n\nThen publish the configurations and migrations:\n\n```bash\nphp artisan vendor:publish --provider=\"Te7aHoudini\\LaravelTrix\\LaravelTrixServiceProvider\"\n```\n\nAfter the migration has been published then run the migrations to create required tables:\n\n```bash\nphp artisan migrate\n```\n\nthen add `@trixassets` directive at the head tag of your html\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        @trixassets\n    \u003c/head\u003e\n\u003c/html\u003e\n```\n\n\n## Usage\n\nlet's assume we have `Post model` \u0026 want to add trix editor.\n\n### Using @trix($model, $field, $config = [])\nyou can use @trix directive inside any view to render trix editor.\n\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        @trixassets\n    \u003c/head\u003e\n\n    \u003cbody\u003e\n        \u003c!-- notice that content field isn't presented in Post model --\u003e\n        @trix(\\App\\Post::class, 'content')\n    \u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n### Storing Rich Text Fields\nnow lets try to store `content` rich text field when hitting submit button.\n\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        @trixassets\n    \u003c/head\u003e\n\n    \u003cbody\u003e\n        \u003cform method=\"POST\" action=\"{{ route('posts.store') }}\"\u003e\n            @csrf\n            @trix(\\App\\Post::class, 'content')\n            \u003cinput type=\"submit\"\u003e\n        \u003c/form\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\n```\nfirst add `HasTrixRichText` trait to your model\n\n``` php\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Te7aHoudini\\LaravelTrix\\Traits\\HasTrixRichText;\n\nclass Post extends Model\n{\n    use HasTrixRichText;\n\n    protected $guarded = [];\n}\n```\nthen you can easily store any rich text fields by multiple ways:\n\n```php\nPost::create(request()-\u003eall());\n\n//storing must follow this convention (model lowered class name)-trixFields\nPost::create([\n    'post-trixFields' =\u003e request('post-trixFields'),\n]);\n\n```\n\n\n### Render Trix For Existing Model\n\nthere's multiple ways to render trix for already existing model\n\n```php\n\u003c!-- inside view blade file --\u003e\n\n@trix($post, 'content')\n\n{!! $post-\u003etrix('content') !!} //must use HasTrixRichText trait in order for $model-\u003etrix() method work\n\n{!! app('laravel-trix')-\u003emake($post, 'content') !!}\n```\n\n### Render Html For Existing Model\n\nYou can render the html content for already existing model\n\n```php\n\u003c!-- inside view blade file --\u003e\n\n{!! $post-\u003etrixRender('content') !!} //must use HasTrixRichText trait in order for $model-\u003etrixRender() method work\n```\n\n### Storing Attachment\n\nwhen uploading a file to trix editor. an ajax request is sent to `store_attachment_action` in `laravel-trix` config file. which uses [Laravel Storage](https://laravel.com/docs/master/filesystem#introduction) and then this action returns `url` if upload is success according to [Basecamp Trix api](https://github.com/basecamp/trix#storing-attached-files) .\n\nthe uploaded file will be stored in `trix_attachments` table as `pending` attachment.\n\nonce model is saved . all `pending` attachments will have `is_pending` column = `0`\n\nso in order to make storing attachment very easy make sure to use `HasTrixRichText` trait in your model.\n\n```php\nPost::create(request()-\u003eall());\n\n//storing must follow this convention (model lowered class name)-trixFields\n//and for attachment must follow attachment-(model lowered class name)-trixFields\nPost::create([\n    'post-trixFields' =\u003e request('post-trixFields'),\n    'attachment-post-trixFields' =\u003e request('attachment-post-trixFields')\n]);\n\n```\n\n### Changing Storage Disk\n\nyou can change attachment storage disk from `laravel-trix` config file .\n\n```php\nreturn [\n    'storage_disk' =\u003e env('LARAVEL_TRIX_STORAGE_DISK', 'public'),\n\n    'store_attachment_action' =\u003e Te7aHoudini\\LaravelTrix\\Http\\Controllers\\TrixAttachmentController::class . '@store',\n\n    'destroy_attachment_action' =\u003e Te7aHoudini\\LaravelTrix\\Http\\Controllers\\TrixAttachmentController::class . '@destroy',\n];\n```\n\nor if you want to change the storage disk for specific rich text field you can do that\n\n```php\n@trix($post, 'content', ['disk' =\u003e 'local'])\n```\n\n### Deleting Rich Text Field and Attachments\n\nyou can remove related rich text fields and attachments on a model deleting:\n\n```php\nclass Post extends Model\n{\n    use HasTrixRichText;\n\n    protected $guarded = [];\n\n    protected static function boot()\n    {\n        parent::boot();\n\n        static::deleted(function ($post) {\n            $post-\u003etrixRichText-\u003eeach-\u003edelete();\n            $post-\u003etrixAttachments-\u003eeach-\u003epurge();\n        });\n    }\n}\n```\n\n### Configuration Table\n\nif you want to hide buttons or toolbar you can do this. for more configuration refer to the table below.\n\n```php\n@trix($post, 'content', [ 'hideButtonIcons' =\u003e ['attach', 'bold'] ])\n\n@trix($post, 'content', [ 'hideTools' =\u003e ['text-tools'] ])\n\n```\n| configuration   | type    | values | description\n|-----------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------\n| hideToolbar | Boolean | True or False | hides the the toolbar\n| hideTools   | Array   | ['text-tools', 'block-tools', 'file-tools', 'history-tools'] | hides group of buttons\n| hideButtonIcons   | Array   | ['attach', 'bold', 'italic', 'strike', 'link', 'heading-1', 'quote', 'code', 'bullet-list', 'number-list',  'decrease-nesting-level', 'increase-nesting-level'] | hides a single button\n| disk   | String   | 'local' or 's3' or 'any-disk' | sets the attachment storage per field\n| id     | String  | 'any-value-you-want' | the id of input which renders [trix. check this link](https://github.com/basecamp/trix#integrating-with-forms) . current id follows this convention `(model lowered class name)-field-modelId` like `post-content-1` or `post-content-new-model`\n| containerElement | String | valid html tag like `span` or `div` | default container tag is set to `span` you can change it as you want\n\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n### Security\n\nIf you discover any security related issues, please email ahmedabdelftah95165@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Ahmed Abd El Ftah](https://github.com/Te7a-Houdini)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaelftah%2Flaravel-trix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famaelftah%2Flaravel-trix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaelftah%2Flaravel-trix/lists"}