Chris1904
2 years ago
114
4
Laravel

must be an instance of Facades\Validator, instance of Validation\Validator given

Posted 2 years ago by Chris1904

Hi everyone,

When I try to submit a new discussion I receive this error:

FatalThrowableError in ChatterBeforeNewDiscussion.php line 26:
Type error: Argument 2 passed to DevDojo\Chatter\Events\ChatterBeforeNewDiscussion::__construct() must be an instance of Illuminate\Support\Facades\Validator, instance of Illuminate\Validation\Validator given, called in /var/www/vhosts/domain/httpdocs/vendor/devdojo/chatter/src/Controllers/ChatterDiscussionController.php on line 66

ChatterBeforeNewDiscussion.php line 26

use Validator;
...

public function __construct(Request $request, Validator $validator)
{
    // no error message if I comment out the following lines
    $this->request = $request;
    $this->validator = $validator;
}

ChatterDiscussionController.php on line 66

use Validator;
...

$validator = Validator::make($request->all(), [
    'title'               => 'required|min:5|max:255',
    'body_content'        => 'required|min:10',
    'chatter_category_id' => 'required',
]);

Event::fire(new ChatterBeforeNewDiscussion($request, $validator));

Am I doing anything wrong here? The second argument seems to be an instance of Illuminate\Support\Facades\Validator so I don't really understand this error message. :-(

Any help is appreciated!

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