[ 'path' => 'uploads/images', 'max_size' => 10 * 1024 * 1024, // 10MB 'allowed_types' => ['image/jpeg', 'image/png', 'image/gif', 'image/webp'], 'extensions' => ['jpg', 'jpeg', 'png', 'gif', 'webp'] ], 'avatar' => [ 'path' => 'uploads/avatars', 'max_size' => 5 * 1024 * 1024, // 5MB 'allowed_types' => ['image/jpeg', 'image/png', 'image/webp'], 'extensions' => ['jpg', 'jpeg', 'png', 'webp'] ], 'document' => [ 'path' => 'uploads/documents', 'max_size' => 20 * 1024 * 1024, // 20MB 'allowed_types' => [ 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'extensions' => ['pdf', 'doc', 'docx', 'xls', 'xlsx'] ], 'usedcar' => [ 'path' => 'uploads/usedcar', 'max_size' => 10 * 1024 * 1024, // 10MB 'allowed_types' => ['image/jpeg', 'image/png', 'image/webp', 'image/gif'], 'extensions' => ['jpg', 'jpeg', 'png', 'webp', 'gif'] ], 'other' => [ 'path' => 'uploads/others', 'max_size' => 5 * 1024 * 1024, // 5MB 'allowed_types' => [], 'extensions' => [] ] ]; /** * 关联用户 */ public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } /** * 获取分区配置 */ public static function getPartitionConfig(string $partition): ?array { return self::$uploadPartitions[$partition] ?? self::$uploadPartitions['other']; } /** * 获取所有分区配置 */ public static function getAllPartitions(): array { return self::$uploadPartitions; } }