<?php

namespace App\Models;

use Illuminate\Support\Facades\Storage;

class claimcomment extends Central
{
    protected $table = 'user_claim_comments';
    protected $primaryKey = 'id';
    protected $guarded = [];

    public $module = 'claimcomment';
    public $timestamps = true;

    public function __construct()
    {
        parent::__construct();
    }

    public static function querySelect()
    {
        return "  SELECT user_claim_comments.* FROM user_claim_comments  ";
    }

    public static function queryWhere()
    {
        return "  WHERE user_claim_comments.id IS NOT NULL ";
    }

    public static function queryGroup()
    {
        return "  ";
    }

    public function getAttachmentsAttribute($value)
    {
        if ($value) {
            $attachmentsURLs = [];
            foreach (json_decode($value) as $attachment)
                $attachmentsURLs[] = Storage::disk('do-spaces')->temporaryUrl($attachment, now()->addHour());

            return $attachmentsURLs;
        } else
            return [];
    }
}
