<?php

namespace App\Models;

use App\Http\Helpers\Hasher;
use Carbon\Carbon;

use Illuminate\Database\Eloquent\Model;

class Permission extends Model
{
	protected $table = 'permissions';

    protected $hidden = [
        'pivot'
    ];

    protected $appends = ['hash_id'];

    public function getHashIdAttribute()
    {
        return Hasher::encode('permissions', $this->id);
    }

    public function getUpdatedAtAttribute($date) 
    {
        return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
    }

    public function getCreatedAtAttribute($date) 
    {
        return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
    }
}
