lundi 26 août 2019

Laravel Request Validation, unique_if?

I know that there is already required_if validation of Laravel. Is there any validation that uses unique_if? I will just use this validation, if the action is add, the data should be unique in library_name, while if action is update, it will be disabled

private function validateRequest($oRequest)
    {
        $aData = $oRequest->validate([
            'idx'                 => 'required_if:action,==,Update',
            'library_name'        => 'unique:tbl_library,library_name|min:3|max:100|nullable',
            'sub_component_idx'   => 'exists:tbl_sub_component,idx|integer|max:11|required',
            'library_description' => 'min:3|max:1000|nullable',
            'library_psd'         => 'nullable',
            'library_html'        => 'nullable',
            'library_css'         => 'nullable',
            'library_js'          => 'nullable',
            'tags'                => 'nullable'
        ]);

        return $aData;
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire