Fixes for SQL server

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

namespace App\Models;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Config;
use Illuminate\Database\Eloquent\Model;

use Carbon\Carbon;

class Exams extends Model{
    protected $table = 'Test_Main';
    protected $primaryKey = 'id';
    public $timestamps = true;
    const CREATED_AT = 'created_time';
    const UPDATED_AT = 'updated_time';
    //protected $dateFormat = 'M j Y h:i:s:000A';

    const DT_TOTAL = 1;
    const DT_FILTERED = 2;

    //Fix for MSSQL Server
    public function getDateFormat()
    {
        return 'Y-m-d H:i:s.u';
    }

    //Fix for MSSQL Server
    public function fromDateTime($value)
    {
        return substr(parent::fromDateTime($value), 0, -3);
    }
}

Reference:

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