:::

9-6 後台加入所見即所得編輯器

  1. 新的安裝方式:https://github.com/laravel-admin-extensions/ckeditor
  2. 安裝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,
            ],
        ],
    ],

     

  3. 開啟\專案\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()

  4. 再重整一下畫面就可以看到編輯器被載入囉!

到GitHub觀看此單元程式異動


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1417%26tbsn%3D43

計數器

今天: 4990499049904990
昨天: 2489248924892489
總計: 8026972802697280269728026972802697280269728026972