JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "CsvExport-20260314162707.php"

Full Path: /home/markqprx/iniasli.pro/common-20260222054425/Csv/CsvExport-20260314162707.php
File size: 755 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace Common\Csv;

use Illuminate\Database\Eloquent\Model;
use Storage;

class CsvExport extends Model
{
    protected $guarded = ['id'];

    protected $casts = [
        'id' => 'integer',
        'user_id' => 'integer',
    ];

    const MODEL_TYPE = 'csv_export';

    public static function getModelTypeAttribute(): string
    {
        return self::MODEL_TYPE;
    }

    public function storeFile($stream): bool
    {
        Storage::delete($this->filePath());
        return Storage::writeStream($this->filePath(), $stream);
    }

    public function filePath(): string
    {
        return "exports/csv/{$this->uuid}.csv";
    }

    public function downloadLink(): string
    {
        return url("csv/download/$this->id");
    }
}