Category Archives: Laravel

Eloquent Model Example

 

Fixes for SQL server

Solution for Carbon separator error: Override 2 functions for each model.

Reference:

  1. https://github.com/laravel/framework/issues/14247
  2. https://laracasts.com/discuss/channels/eloquent/timestampdatetime-issue-with-51-sqlserver?page=1

 

Laravel with SQL Server

Download Drivers for PHP for MSSQL Server:

https://docs.microsoft.com/zh-tw/sql/connect/php/download-drivers-php-sql-server?view=sql-server-2017

PHP 7.2 -> Microsoft Drivers 5.3 for PHP for SQL Server (Mapping table)

Install ODBC Driver:

https://www.microsoft.com/en-us/download/details.aspx?id=36434

Reference:

  1. Enable PHP extensions:
    https://stackoverflow.com/questions/16223788/how-can-i-install-pdo-sqlsrv-on-my-windows-2008-server-2008-r2
  2. PHP 7:
    https://devmanna.blogspot.com/2016/06/howto-laravel-sql-server-connection.html

Localization tips

Middleware will be processed before construct, so manipulate session in construct will not work.

 

Method links does not exist error

When using voyager with(‘translations’) and paginate together, this error occurs when creating pagination links.

Original:

Solution:

Solution 2:

 

Reference:

  1. https://laracasts.com/discuss/channels/laravel/links-method-doesnt-exist-after-sortbydesc-on-hasmany