<?php

namespace Ignite\Core\Entities;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class TransactionResource.
 *
 * @property int $id
 * @property string $identfier
 * @property int $related_id
 * @property string $related_type
 * @property string $related_name
 * @property string $type
 * @property string $description
 * @property string $notes
 * @property float $value
 * @property Carbon $tax_date
 * @property Carbon $transaction_date
 * @property string $hash
 * @property Carbon $created_at
 * @property Carbon $updated_at
 * @method static Builder byIds($ids)
 */
class TransactionResource extends Transaction
{
    use SoftDeletes;

    /**
     * The name of the table.
     *
     * @var string
     */
    protected $table = 'core_transaction_resource';

    /**
     * The guarded attributes.
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * Query for multiple IDs.
     *
     * @param  Builder      $query
     * @param  array|string $ids
     * @return Builder
     */
    public function scopeByIds(Builder $query, $ids): Builder
    {
        if (is_string($ids)) {
            $ids = preg_split('/\s?,\s?/', $ids);
        }

        $query->whereIn('id', $ids);

        return $query;
    }
}
