方法Illuminate \ Validation \ Validator :: validateVideo不存在

达维萨拉拉隆索

我正在托盘上载带有dropzone的视频,我在控制器,视图,模型,特征等中执行了方法。但是当我调用函数的路由时,返回了以下内容:

Method Illuminate\Validation\Validator::validateVideo does not exist.

我知道我的问题在哪里...

我附上我的实际代码:

路线

Route::post('uploads/storeVideo', 'UploadController@storeVideo')->name('medias.createVideo');

控制者

public function storeVideo(UploadRequest $request)
    {
        $input = $request->all();
        try {
            $upload = $this->uploadRepository->create($input);
            $upload->addMedia($input['file'])
                    ->withCustomProperties(['uuid' => $input['uuid'], 'user_id' => auth()->id()])
                    ->toMediaCollection($input['field']);           
        } catch (ValidatorException $e) {
            return $this->sendResponse(false, $e->getMessage());
        }
    }

视图

<div class="form-group row">
            {!! Form::label('video', trans("lang.restaurant_video"), ['class' => 'col-3 control-label text-right ']) !!}
            <div class="col-9">
                <div style="width: 100%" class="dropzone video" id="video" data-field="video">
                    <input type="hidden" name="video">
                </div>
                <a href="#loadMediaModal" data-dropzone="video" data-toggle="modal" data-target="#mediaModal" class="btn btn-outline-{{setting('theme_color','primary')}} btn-sm float-right mt-1">{{ trans('lang.media_select')}}</a>
                <div class="form-text text-muted w-50">
                    {{ trans("lang.restaurant_video_help") }}
                </div>
            </div>
        </div>
        @prepend('scripts')
            <script type="text/javascript">
                var var15671147011688676454bleVideo = '';
                @if(isset($restaurant) && $restaurant->hasMedia('video'))
                    var15671147011688676454bleVideo = {
                        name: "{!! $restaurant->getFirstMediaVideoUrl('video')->name !!}",
                        size: "{!! $restaurant->getFirstMediaVideoUrl('video')->size !!}",
                        type: "{!! $restaurant->getFirstMediaVideoUrl('video')->mime_type !!}",
                        collection_name: "{!! $restaurant->getFirstMediaVideoUrl('video')->collection_name !!}"
                    };
                @endif
                var dz_var15671147011688676454bleVideo = $(".dropzone.video").dropzone({
                        url: "{!! url('panel/uploads/storeVideo') !!}",

                        /*dictDefaultMessage: "{{trans('validation.dropzone_dictDefaultMessage')}}",
                        dictFallbackMessage: "{{trans('validation.dropzone_dictFallbackMessage')}}",
                        dictFallbackText: "{{trans('validation.dropzone_dictFallbackText')}}",
                        dictFileTooBig: "{{trans('validation.dropzone_dictFileTooBig', [ 'size' => config('medialibrary.max_file_size') / 1024 / 1024 ])}}",
                        dictInvalidFileType: "{{trans('validation.dropzone_dictInvalidFileType')}}",
                        dictResponseError: "{{trans('validation.dropzone_dictResponseError')}}",
                        dictCancelUpload: "{{trans('validation.dropzone_dictCancelUpload')}}",
                        dictCancelUploadConfirmation: "{{trans('validation.dropzone_dictCancelUploadConfirmation')}}",
                        dictRemoveFile: "{{trans('validation.dropzone_dictRemoveFile')}}",*/
                        dictMaxFilesExceeded: "{{ trans('validation.dropzone_dictMaxFilesExceeded') }}",
                        maxFilesize: {!! config('medialibrary.max_file_size_video') / 1024 / 1024 !!},
                        acceptedFiles: "video/*",  
                        addRemoveLinks: true,
                        maxFiles: 1,
                        
                        init: function () {
                            @if(isset($restaurant) && $restaurant->hasMedia('video'))
                                dzInit(this, var15671147011688676454bleVideo, '{!! url($restaurant->getFirstMediaVideoUrl('video','mp4')) !!}')
                            @endif

                            this.on("error", function(file, message) {

                                console.log(message);

                                $('.video').after(`<ul class="alert alert-danger" style="list-style: none;">
                                                        <li>
                                                            ${message}
                                                        </li>
                                                    </ul>`);
                                this.removeFile(file); 
                            });

                            this.on("success", function(file, message) {
                                $('.alert-danger').remove();
                                $('.video').after(`<ul class="alert alert-success" style="list-style: none;">
                                                        <li>
                                                            {{trans('validation.dropzone_success')}}
                                                        </li>
                                                    </ul>`);
                            });


                        },
                        accept: function (file, done) {
                            dzAccept(file, done, this.element, "{!! config('medialibrary.videos_folder') !!}");
                        },
                        sending: function (file, xhr, formData) {
                            dzSending(this, file, formData, '{!! csrf_token() !!}');
                        },
                        maxfilesexceeded: function (file) {
                            dz_var15671147011688676454bleVideo[0].mockFile = '';
                            dzMaxfile(this, file);
                        },
                        complete: function (file) {
                            dzComplete(this, file, var15671147011688676454bleVideo, dz_var15671147011688676454bleVideo[0].mockFile);
                            dz_var15671147011688676454bleVideo[0].mockFile = file;
                        },
                        removedfile: function (file) {
                            dzRemoveFile(
                                file, var15671147011688676454bleVideo, '{!! url("panel/restaurants/remove-media") !!}',
                                'video', '{!! isset($restaurant) ? $restaurant->id : 0 !!}', '{!! url("panel/uploads/clear") !!}', '{!! csrf_token() !!}'
                            );
                        }
                    });
                dz_var15671147011688676454bleVideo[0].mockFile = var15671147011688676454bleVideo;
                dropzoneFields['video'] = dz_var15671147011688676454bleVideo;
            </script>
        @endprepend

Laravel中的UploadRequest deault

public function rules()
    {
        return [
            'file' => 'image|video|mimes:jpeg,png,jpg,gif,svg,mp4,mov,avi,mkv',
        ];
    }

模型

// VIDEO AND ALLOWED TYPES
    public function getFirstMediaUrlVideo($collectionName = 'default', $conversion = '')
    {
        $url = $this->getFirstMediaVideoUrlTrait($collectionName);
        if($url){
            $array = explode('.', $url);
            $extension = strtolower(end($array));
            if (in_array($extension, ['.mp4', '.mkv'])) {
                return asset($this->getFirstMediaVideoUrlTrait($collectionName, $conversion));
            } else {
                return asset('videos/' . $extension . '.mp4');
            }
        }else{
            return asset('videos/video_default.mp4');
        }
    }

感谢所有帮助,我不知道为什么会这样。谢谢

肯尼·霍纳(Kenny Horna)

您的错误,至少是第一个错误,在这里:

public function rules()
{
    return [
        'file' => 'image|video|mimes:jpeg,png,jpg,gif,svg,mp4,mov,avi,mkv',
    ];                   ^^^^^
}

没有video验证规则(您可以在此处查看完整列表)。相反,您应该做的是仅使用mimes(或mimetypes)规则:

return [
    'file' => 'mimes:mp4,mov,avi,mkv',
];    

有关您可以使用的mime扩展程序的完整列表,请参见清单

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

方法 Illuminate\Validation\Validator::validateNullablerequired 不存在

来自分类Dev

方法 App\Http\Controllers\Auth\RegisterController::validator 不存在

来自分类Dev

“ message”:“方法Illuminate \\ Auth \\ SessionGuard :: factory不存在。”,

来自分类Dev

方法Illuminate \ Database \ Eloquent \ Collection :: books不存在。(laravel)

来自分类Dev

方法Illuminate \ Database \ Eloquent \ Collection :: paginate不存在

来自分类Dev

方法Illuminate \ View \ View :: header不存在

来自分类Dev

方法 Illuminate\Support\Collection::offset 不存在

来自分类Dev

Laravel 方法 Illuminate\Mail\Mailer::test 不存在

来自分类Dev

错误 = 方法 Illuminate\Http\UploadedFile::save 不存在

来自分类Dev

方法 Illuminate\Http\Request::date 不存在

来自分类Dev

方法 Illuminate\Database\Eloquent\Collection::links 不存在

来自分类Dev

Laravel 错误:方法 Illuminate\Auth\SessionGuard::venue 不存在

来自分类Dev

BadMethodCallException: 方法 Illuminate\Routing\Route::get 不存在

来自分类Dev

的方法不存在

来自分类Dev

调用未定义的方法 Cake\Validation\Validator::money()

来自分类Dev

方法分页不存在

来自分类Dev

unbind()方法不存在

来自分类Dev

方法/属性不存在

来自分类Dev

方法链接不存在

来自分类Dev

日期不存在的方法

来自分类Dev

方法 addSelect 不存在

来自分类Dev

方法链接不存在。

来自分类Dev

方法 whereRaw 不存在

来自分类Dev

方法Illuminate \ Routing \ Route :: resource不存在。在Macroable.php第78行

来自分类Dev

Laravel 8中的Illuminate \ Database \ Eloquent \ Collection :: attach方法不存在错误

来自分类Dev

错误方法Illuminate \\ Database \\ Eloquent \\ Collection :: save不存在。在Laravel

来自分类Dev

Laravel 8:方法Illuminate \ Database \ Eloquent \ Collection :: latest不存在

来自分类Dev

方法 Illuminate\Http\RedirectResponse::getData 不存在。登录页面后

来自分类Dev

如果不存在则生成方法

Related 相关文章

  1. 1

    方法 Illuminate\Validation\Validator::validateNullablerequired 不存在

  2. 2

    方法 App\Http\Controllers\Auth\RegisterController::validator 不存在

  3. 3

    “ message”:“方法Illuminate \\ Auth \\ SessionGuard :: factory不存在。”,

  4. 4

    方法Illuminate \ Database \ Eloquent \ Collection :: books不存在。(laravel)

  5. 5

    方法Illuminate \ Database \ Eloquent \ Collection :: paginate不存在

  6. 6

    方法Illuminate \ View \ View :: header不存在

  7. 7

    方法 Illuminate\Support\Collection::offset 不存在

  8. 8

    Laravel 方法 Illuminate\Mail\Mailer::test 不存在

  9. 9

    错误 = 方法 Illuminate\Http\UploadedFile::save 不存在

  10. 10

    方法 Illuminate\Http\Request::date 不存在

  11. 11

    方法 Illuminate\Database\Eloquent\Collection::links 不存在

  12. 12

    Laravel 错误:方法 Illuminate\Auth\SessionGuard::venue 不存在

  13. 13

    BadMethodCallException: 方法 Illuminate\Routing\Route::get 不存在

  14. 14

    的方法不存在

  15. 15

    调用未定义的方法 Cake\Validation\Validator::money()

  16. 16

    方法分页不存在

  17. 17

    unbind()方法不存在

  18. 18

    方法/属性不存在

  19. 19

    方法链接不存在

  20. 20

    日期不存在的方法

  21. 21

    方法 addSelect 不存在

  22. 22

    方法链接不存在。

  23. 23

    方法 whereRaw 不存在

  24. 24

    方法Illuminate \ Routing \ Route :: resource不存在。在Macroable.php第78行

  25. 25

    Laravel 8中的Illuminate \ Database \ Eloquent \ Collection :: attach方法不存在错误

  26. 26

    错误方法Illuminate \\ Database \\ Eloquent \\ Collection :: save不存在。在Laravel

  27. 27

    Laravel 8:方法Illuminate \ Database \ Eloquent \ Collection :: latest不存在

  28. 28

    方法 Illuminate\Http\RedirectResponse::getData 不存在。登录页面后

  29. 29

    如果不存在则生成方法

热门标签

归档