krgm.so-manager-dev.com/app/Support/Files.php

31 lines
614 B
PHP

<?php
namespace App\Support;
use Illuminate\Support\Facades\Storage;
/**
* ファイルユーティリティ
*/
class Files
{
/**
* 一時ファイルパス生成
*/
public static function tempPath(string $prefix = 'sm_', string $suffix = '.tmp'): string
{
$dir = sys_get_temp_dir();
return $dir.DIRECTORY_SEPARATOR.$prefix.uniqid('', true).$suffix;
}
/**
* ストレージに保存(簡易)
*/
public static function putPublic(string $path, string $contents): bool
{
return Storage::disk('public')->put($path, $contents);
}
}