![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/dceprojects.corals.io/Corals/modules/Timesheet/Models/ |
<?php namespace Corals\Modules\Timesheet\Models; use Corals\Foundation\Models\BaseModel; use Corals\Foundation\Transformers\PresentableTrait; use Corals\Modules\ProjectPlan\Models\Project; use Corals\Modules\Utility\Models\ListOfValue\ListOfValue; use Corals\User\Models\User; use Illuminate\Support\Str; use Spatie\Activitylog\Traits\LogsActivity; class Entry extends BaseModel { use PresentableTrait, LogsActivity; protected $table = 'ts_entries'; /** * Model configuration. * @var string */ public $config = 'timesheet.models.entry'; protected $formModalConfig = ['size' => '']; protected static $logAttributes = []; protected $casts = [ 'properties' => 'json', ]; protected $guarded = ['id']; public function entrieable() { return $this->morphTo(); } public function project() { return $this->belongsTo(Project::class, 'project_id'); } public function user() { return $this->belongsTo(User::class, 'user_id'); } public function getLoggedTimeAttribute($hours = null, $minutes = null) { $hours = $hours ?? $this->hours; $minutes = $minutes ?? $this->minutes; $totalMinutes = (($hours * 60) + $minutes); $totalHours = floor($totalMinutes / 60); $remainingMinutes = $totalMinutes % 60; return Str::padLeft($totalHours, 2, 0) . ':' . Str::padLeft($remainingMinutes, 2, 0); } public function department() { return $this->belongsTo(ListOfValue::class, 'department_code', 'code'); } }