<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class UserActivity extends Model
{
    protected $guarded = array('id');
    public $table = "user_activities";
    // protected $appends = ['activity_time'];

    public function userInfo(){
      return $this->hasOne('App\Models\StaffMember', 'id', 'user_id');
    }
    public function userInfoSystem(){
      return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
    }
    public function getActivityTimeAttribute(){
        $created = $this->created_at;
        $parsed_created_date = Carbon::parse($created);
        $current_date = Carbon::parse(date('Y-m-d'));
        $days = $parsed_created_date->diffForHumans();
        return $days;
    }
}
