Category Archives: Laravel

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

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

UserC for Laravel-Permission

Example

 

RoleC for Laravel-Permission

Example

 

There is no role with id `123` Issue

With laravel-permission package, if you wanna delete a role and the role name is “123”, it seems the package will find it by ID automatically because it’s numerical.

Solution:

Change name from “123” to “v123”, etc.

Share data to all views

Middleware

Kernel

 

Jquery Repeater

Github:

https://github.com/DubFriend/jquery.repeater

Javascript

HTML

 

Black list to hide .env values from debug mode

Append this array to config/app.php