You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tivi_kemana_saja_laravel/app/Helper/FileHelper.php

27 lines
934 B
PHP

<?php
namespace App\Helper;
class FileHelper {
static $allowedVideoExtensions = ['mp4', 'mkv'];
static $allowedApkExtensions = ['apk'];
static function convertToStrJsValidation(array $allowedFileExtensions) {
// add leading '.' for every extension;
foreach($allowedFileExtensions as &$allowedFileExtension) { $allowedFileExtension = ".$allowedFileExtension"; }
unset($allowedFileExtension);
return implode(', ', $allowedFileExtensions);
}
static function convertToStrLaraValidation(array $allowedFileExtensions, $type = 'string') {
$validations = [
'mimes:' . implode(',', $allowedFileExtensions),
'extensions:' . implode(',', $allowedFileExtensions)
];
if($type == 'string') return implode('|', $validations);
else if($type == 'array') return $validations;
else throw new \Exception('Type not valid');
}
}
?>