|
|
@ -1,60 +0,0 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace App\Http\Requests; |
|
|
|
|
|
|
|
use App\Models\Collection; |
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
|
|
|
|
|
|
|
class FileStoreRequest extends FormRequest |
|
|
|
{ |
|
|
|
|
|
|
|
private $collection = null; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
|
|
|
|
$this->collection = Collection::where('name',$this->collection_name)->get(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Determine if the user is authorized to make this request. |
|
|
|
* |
|
|
|
* @return bool |
|
|
|
*/ |
|
|
|
public function authorize() |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
private function getExts() |
|
|
|
{ |
|
|
|
return implode(",",$this->collection->exts); |
|
|
|
} |
|
|
|
|
|
|
|
private function getMimeTypes() |
|
|
|
{ |
|
|
|
return implode(",",$this->collection->mimetypes); |
|
|
|
} |
|
|
|
|
|
|
|
// private function getExt()
|
|
|
|
// {
|
|
|
|
// return implode(",",$this->collection->ext);
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get the validation rules that apply to the request. |
|
|
|
* |
|
|
|
* @return array<string, mixed> |
|
|
|
*/ |
|
|
|
public function rules() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
"ext" => ["mimes:" . $this->getExts], |
|
|
|
"memetype" => ["mimetypes:" . $this->getMimeTypes], |
|
|
|
"width"=> [''], |
|
|
|
"height"=> [''], |
|
|
|
"file_size"=> [''], |
|
|
|
]; |
|
|
|
} |
|
|
|
} |