3 months ago

validation problems

Posted 3 months ago by Lindie2669

What i want to do is: get the variable from the request. Convert the variable to lowercase. Then validate the variable, because the variable is required, has to be smaller then 100 characters and needs to be unique, when the validation suceeds it need to be submitted to the database.

But i can't get it to work in that exact order. This is my code at the moment:

public function store()
        $tag = new Tag();
        $tag->tag_naam = strtolower(request('tag_naam'));

        $validatedTag = $tag->validate([
            'tag_naam' => 'required || max:100 || unique:tags'

      return redirect('/backend/tag')->withInput();

The error message:

Call to undefined method App\Tag::validate()

Does anyone know how to get it to work?

Please sign in or create an account to participate in this conversation.