Category Archives: Laravel

Where with Subquery

Laravel Example

SQL

 

Reference:

  1. https://justcode.ikeepstudying.com/2016/08/mysql%E5%85%A5%E9%97%A8-%E4%B9%9D-%E5%AD%90%E6%9F%A5%E8%AF%A2-subquery/
  2. https://ithelp.ithome.com.tw/articles/10032121

Order by Array

Sample

Reference

  1. https://stackoverflow.com/questions/8055138/mysql-sort-order-by-array-value
  2. https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_field
  3. Could be replaced with orderRaw()
    https://laravel.com/docs/8.x/queries

Get Daily Data using Laravel Query Builder

Query Builder

 

Laravel API

Token

Reference:

  1. https://laravel.com/docs/5.8/api-authentication

Create Path with Laravel File Facade

 

Sort by array values

Reference:

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