You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
656 B

1 month ago
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;
class ApplicationFile extends Model
{
protected $fillable = [
'application_id',
'kind',
'disk',
'path',
'original_name',
'size',
'mime',
];
public function application(): BelongsTo
{
return $this->belongsTo(Application::class);
}
public function publicUrl(): string
{
1 month ago
$u = Storage::disk($this->disk)->url($this->path);
return preg_replace('#([^:])//+#', '$1/', $u) ?? $u;
1 month ago
}
}