Browse Source

add discount_id

pull/1/head
farhantock 9 months ago
parent
commit
53b37f87ea
  1. 3
      app/Models/Company.php
  2. 29
      app/Models/User.php

3
app/Models/Company.php

@ -34,6 +34,7 @@ class Company extends Model
'updated_by',
'cluster',
'type_account',
'date_register'
'date_register',
'discount_id'
];
}

29
app/Models/User.php

@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;
use Carbon\Carbon;
class User extends Model implements AuthenticatableContract, AuthorizableContract,JWTSubject
class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
{
use Authenticatable, Authorizable, HasFactory;
@ -24,7 +24,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource'
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id'
];
const CREATED_AT = 'created_at';
@ -74,20 +74,18 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
{
$workingTime = array(
"from"=> Carbon::createFromTimeString($f, $tz),
"to"=> Carbon::createFromTimeString($t, $tz)
"from" => Carbon::createFromTimeString($f, $tz),
"to" => Carbon::createFromTimeString($t, $tz)
);
$userShift = UserShift::where('user_id', )
$userShift = UserShift::where('user_id',)
->orderByDesc('from_date')
->first();
$shift = null;
if ($userShift !== null)
{
if ($userShift !== null) {
$shiftId = null;
switch ($ts->shortEnglishDayOfWeek)
{
switch ($ts->shortEnglishDayOfWeek) {
case "Mon":
$shiftId = $userShift->mon_shift_id;
break;
@ -123,8 +121,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
if ($shift !== null)
{
if ($shift !== null) {
$from = Carbon::createFromTimeString($shift->start_time, $tz)
->subMinutes($shift->flex_time_minute);
$to = Carbon::createFromTimeString($shift->end_time, $tz)
@ -150,16 +147,14 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
{
$ts = $at;
if ($at !== null)
{
if ($at !== null) {
$ts = Carbon::now($tz);
}
$tsSec = $ts->secondsSinceMidnight();
$status = "";
$wt = $this->getWorkingTime($ts, $tz);
if ($wt === null)
{
if ($wt === null) {
$status = self::HOLIDAY;
} else {
$from = $wt->from;
@ -168,7 +163,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
$tsTo = $to->secondsSinceMidnight();
if ($from->greaterThan($to)) {
$tsMid = 24*60*60 - $tsFrom;
$tsMid = 24 * 60 * 60 - $tsFrom;
if ($tsSec >= $tsFrom || $tsSec < $tsTo) {
$status = self::INSIDE;
} else {
@ -194,7 +189,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
return array(
"status"=>$status,
"status" => $status,
"ts" => $ts,
"clock_in" => $clockIn,
"clock_out" => $clockOut

Loading…
Cancel
Save