Category Archives: PHP

Sort by array values

Reference:

  1. https://stackoverflow.com/questions/8055138/mysql-sort-order-by-array-value

Laravel Cookie

Save cookie with redirect or response

Get cookie

Reference:

  1. https://laravel.com/docs/5.8/requests#cookies
  2. https://laravel.com/docs/5.8/responses#attaching-cookies-to-responses

AES Decrypt

AES/CBC/PKCS5Padding encryption

  1. MD5 Digest the password(REST_API_KEY) using SHA-256
  2. iv parameter is empty
  3. Decrypt the encrypted contents using AES/CBC/PKCS5Padding

Laravel verifycsrftoken except not working

Path issue

Example URL: http://localhost:8000/wingpay/listener

Reference:

  1. https://stackoverflow.com/questions/32751063/laravel-verifycsrftoken-exception-not-working

Transaction and lock tables in Laravel

Example

Reference:

  1. https://stackoverflow.com/questions/53522444/how-to-lock-table-with-laravel
  2. https://www.mysql.tw/2018/06/mysql-lock-table-lockrow-lock.html
  3. https://xyz.cinc.biz/2013/04/mysql-lock-tables.html
  4. https://laravel.com/docs/6.x/queries#pessimistic-locking

Laravel Storage Extension Issue

Script

Get correct MIME Type

Reference:

  1. https://laracasts.com/discuss/channels/requests/putfile-method-stores-mp3-files-as-bin-in-laravel?page=0
  2. https://laracasts.com/discuss/channels/laravel/laravel-54-uploadedfilegetmimetype-returns-incorrect-mimetype

Read CSV File

Don’t use phpspreadsheet to read .csv file because there could be some bugs and get incorrect result.

Reference:

  1. https://www.php.net/manual/zh/function.fgetcsv

PHP to handle 0 zero value

 

UserC for Laravel-Permission

Example