add publish module
This commit is contained in:
parent
100f6db9a6
commit
ffbbc04206
93 changed files with 8150 additions and 10228 deletions
66
app/Rules/RdrFiletypes.php
Normal file
66
app/Rules/RdrFiletypes.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class RdrFiletypes implements Rule
|
||||
{
|
||||
protected $filetypes;
|
||||
// protected $maxFileSize;
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->filetypes = Config::get('enums.filetypes_allowed', ['pdf']);
|
||||
// $this->maxFileSize = Config::get('enums.max_filesize');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
//return Rule::in($this->filetypes);
|
||||
return $value->getPath() != '' &&
|
||||
in_array($value->guessExtension(), $this->filetypes); // &&
|
||||
// $this->getSize($attribute, $value) <= $this->maxFileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'attribute :attribute has not a valid mime type.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of an attribute.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
private function getSize($attribute, $value)
|
||||
{
|
||||
if (is_numeric($value) && $hasNumeric) {
|
||||
return array_get($this->data, $attribute);
|
||||
} elseif (is_array($value)) {
|
||||
return count($value);
|
||||
} elseif ($value instanceof File) {
|
||||
return $value->getSize() / 1024;
|
||||
}
|
||||
return mb_strlen($value);
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue