Framework: BadMethodCallException: Method Illuminate\Validation\Validator::validateText does not exist.

Created on 30 Oct 2018  路  3Comments  路  Source: laravel/framework

Laravel Version: 5.7.*
PHP Version: 7.1.6
Database Driver & Version:

Description:

Hi ! I'm not sure if this is my mistake or an issue with laravel. I followed the tutorial on site to validate a simple form and I get BadMethodCallException: Method Illuminate\Validation\Validator::validateText does not exist. instead.

This is my controller. By default I start by invoking the index() method. Error occurs inside _validate(), at if($ret -> fails())

<?php

namespace App\Http\Controllers\Students\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\Controller;
use App\Students;
use Validator;

class Register extends Controller
{
    /*
    * Vars
    */
    protected $guard = 'students';
    protected $provider = 'students';
    protected $success = '/students/dashboard';
    protected $fail = '/register#students';

    /*
    *   Some construct
    */
    public function __construct()
    {
        if(Auth::guard($this -> guard) -> check())
            return redirect($this -> success);
    }

    /*
    *   Bind all methods
    */
    public function index(Request $request)
    {
        $this -> _validate($request);

        $user = $this -> register($request -> input());

        Auth::guard($this -> guard) -> login($user);

        return redirect($this -> success);
    }

    /*
    *   Validate the form
    */
    protected function _validate(Request $request)
    {
        $ret = Validator::make($request -> input(), [
            'name' => 'required|text|max:255',
            'email' => 'required|email|unique:' . $this -> provider,
            'password' => 'required|min:6',
        ]);

        if($ret -> fails())
            return redirect() -> to($this -> fail)
                                -> withInput()
                                -> withErrors($ret);
    }

    /*
    *   Register the user
    */
    protected function register(array $data)
    {
        return Students::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }

}

Most helpful comment

There is no text validation rule. Where did you read about it?

I assume you want to use 'name' => 'required|string|max:255'.

All 3 comments

There is no text validation rule. Where did you read about it?

I assume you want to use 'name' => 'required|string|max:255'.

Thank you for reply

@staudenmeir your solution made my day really thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

YannPl picture YannPl  路  3Comments

PhiloNL picture PhiloNL  路  3Comments

gabriellimo picture gabriellimo  路  3Comments