Category Archives: Web Tools

Customize tinymce in Voyager

Add additional_js:

https://docs.laravelvoyager.com/customization/additional-css-js

‘js/custom.js’ => ‘public/js/custom.js’

Add callback function in additional js:

https://docs.laravelvoyager.com/customization/tinymce

Rename or copy plugin.min.js to plugin.js

TinyMCE will find plugin.js of each plugins in public\vendor\tcg\voyager\assets\js\plugins
https://www.tiny.cloud/docs/advanced/creating-a-plugin/

Example:

 

Reference:

  1. https://github.com/the-control-group/voyager/issues/1945
  2. Remove doctype and html tags that generated by tinymce automatically: Remove fullpage plugin.
    https://stackoverflow.com/questions/17829239/how-can-i-stop-tinymce-from-adding-doctype-htmlhtmlhead-headbody-to-e
  3. https://stackoverflow.com/questions/6266487/tinymce-allow-all-html-tag
  4. https://stackoverflow.com/questions/7744903/tinymce-allow-data-attribute

Show custom error messages from server side

The key is to add a listener to “xhr.dt” event before initialize datatable plugin.

Server side:

 

Reference:

  1. https://datatables.net/reference/event/xhr

Custom http error response in JSON

Server side (PHP):

Client (with datatable):

Result in Chrome dev tool:

Phpspreadsheet (PHP Excel)

Phpspreadsheet: (phpexcel is deprecated):

https://github.com/PHPOffice/PhpSpreadsheet

Don’t use heading as data key:

/config/excel.php: heading => false;

Setting a cell value by column and row

Retrieving a cell value by column and row

Reference:

Export:

Import:

 

Datatable Server Side Processing (Laravel)

Javascript:

Config:

 

Controller:

Model:

 

SendGrid API Example

Doc: https://github.com/sendgrid/sendgrid-php

Complete example:
https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md#attachments

Example: