9-6
後台加入所見即所得編輯器
- 新的安裝方式:https://github.com/laravel-admin-extensions/ckeditor
- 安裝ckeditor後台擴充套件:
composer require laravel-admin-ext/ckeditor
然後發佈相關檔案到對應資料夾
php artisan vendor:publish --tag=laravel-admin-ckeditor
編輯後台設定檔 config/admin.php
的最下面:
'extensions' => [
'ckeditor' => [
//Set to false if you want to disable this extension
'enable' => true,
// Editor configuration
'config' => [
'lang' => 'zh-TW',
'height' => 300,
],
],
],
- 開啟
\專案\app\Admin\Controllers\ProductController.php
,修改form()
的部份
protected function form()
{
$form = new Form(new Product);
$form->text('title', __('Title'))->rules('required');
$form->ckeditor('description', __('Description'))->rules('required');
$form->image('image', __('Image'))->rules('required');
$states = [
'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
];
$form->switch('on_sale', __('On sale'))->states($states)->default(1);
$form->number('price', __('Price'))->default(0)->rules('required|integer|min:0');
return $form;
}
把原先的textarea()
改為ckeditor()
- 再重整一下畫面就可以看到編輯器被載入囉!