no message

This commit is contained in:
hellcat committed 2026-01-21 19:53:48 +08:00
commit ea84bca5e0
93 files changed
+15373

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Casts\Attribute; // 必须加!
use Illuminate\Support\Facades\Storage; // 必须加!
//use Illuminate\Support\Facades\Log;
class UploadImages extends Model
{
protected $guarded = [];
protected function casts(): array
{
return [
'aArticleCode' => 'array',
];
}
protected static function booted(): void
{
static::deleting(function (UploadImages $oImage) {
if ($oImage->sFileName && Storage::disk('upload_images')->exists($oImage->sFileName)) {
Storage::disk('upload_images')->delete($oImage->sFileName);
}
});
}
public function oImageable(): MorphTo
{
return $this->morphTo('oImageable');
}
protected function sPath(): Attribute
{
return Attribute::make(
get: fn (string $value) => Storage::disk('upload_images')->url($value),
);
}
}