Browse Source

fix timezone problem

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
7fd4316fbd
  1. 17
      app/Models/Activity.php
  2. 1
      app/Models/AssignMaterial.php
  3. 8
      app/Models/ReportActivityMaterial.php
  4. 30
      app/Models/RequestMaterial.php

17
app/Models/Activity.php

@ -8,6 +8,7 @@ use App\Models\ReportActivityMaterial;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class Activity extends Model
{
@ -30,6 +31,22 @@ class Activity extends Model
'jobs_done', 'assign_hr', 'assign_material', 'assign_tools'
];
public function getStartDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public function getEndDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public static function boot() {
parent::boot();

1
app/Models/AssignMaterial.php

@ -5,7 +5,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial;
use App\Models\Activity;
use Carbon\Carbon;
class AssignMaterial extends Model
{

8
app/Models/ReportActivityMaterial.php

@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Activity;
use App\Models\AssignMaterial;
use Carbon\Carbon;
class ReportActivityMaterial extends Model
{
@ -18,6 +19,13 @@ class ReportActivityMaterial extends Model
'report_date', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
];
public function getReportDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public static function boot() {
parent::boot();

30
app/Models/RequestMaterial.php

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class RequestMaterial extends Model
{
@ -35,4 +36,33 @@ class RequestMaterial extends Model
'updated_by',
'price'
];
public function getRequiredDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public function getFomDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public function getPrDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
public function getPoDateAttribute($value)
{
return Carbon::createFromTimestamp(strtotime($value))
->timezone(env('APP_TIMEZONE'))
->toDateTimeString();
}
}

Loading…
Cancel
Save