<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

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

/**
 * Class UserUsage
 *
 * @property int $id
 * @property int $user_id
 * @property int $non_watermark_videos_left
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 */
class UserUsage extends Model
{
    protected $table = 'user_usages';

    protected $casts = [
        'user_id' => 'int',
        'non_watermark_videos_left' => 'int',
    ];

    protected $fillable = [
        'user_id',
        'non_watermark_videos_left',
    ];

    protected $hidden = [
        'created_at',
        'updated_at',
        'id',
        'user_id',
    ];

    protected $appends = ['ids'];

    protected function ids(): Attribute
    {
        return Attribute::make(
            get: fn ($value, $attributes) => hashids_encode($attributes['id']),
        );
    }
}
