<?php

namespace App\Foundation;

use Laravel\Sanctum\PersonalAccessToken as SanctumPersonalAccessToken;

class PersonalAccessToken extends SanctumPersonalAccessToken
{
    protected $table = 'app_personal_access_tokens';

    protected $fillable = ['name', 'token', 'abilities', 'expires_at', 'meta'];

    protected $casts = [
        'abilities' => 'json',
        'meta' => 'json',
        'last_used_at' => 'datetime',
        'expires_at' => 'datetime',
    ];

    public function addMeta($data)
    {
        $data = array_merge($this->meta, $data);
        $this->update(['meta' => $data]);
    }
}
