Monthly Archives: March 2021

Prevent Showing expired data when user click back on browser

Solution:

header("Pragma: no-cache");
header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

Reference:

網站使用API存取資料問題

如果是同一個系統,如果把資料存取從controller->model改成controller->api 會有以下問題

  • 增加額外的API開發及管理成本
  • Debug難度變高
  • 開發速度慢
  • Guzzle及postman不支援.host檔的設定,所以不能用 example.test 之類的網址存取API

結論: 不要用API

migrate not work

Error

Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

Solution

  • Change version of “doctrine/dbal” to “^2.0”
    “doctrine/dbal”: “^2.0”,
  • composer update

Eloquent’s save() is not working

Following script will save nothing:

$member = MemberM::where('id', auth::id())
            ->select(
                "name",
                "email",
                "phone",
                "county",
                "district",
                "address",
                "verified", 
                'registered'
                )
            ->first();
$member->registered = 0;
$member->save();

Reason:

Because no primary column in select(), adding “id” column will save this problem.