0
votes

I am using third party laravel forum library and i follow the steps in the tutorial but it gives the following error.

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 /home/mahmood/work/aalaauddin/vendor/devdojo/chatter/src/Controllers/ChatterDiscussionController.php on line 66

Can please someone please help?

1
Try to write this on top use Illuminate\Support\Facades\Validator in this page /home/mahmood/work/aalaauddin/vendor/devdojo/chatter/src/Controllers/ChatterDiscussionController.php - Ahmad Rezk
Thanks Ahmad, however same error still there. - Mohamud
Can you share code of this page ChatterDisc‌​ussionController.php - Ahmad Rezk
The code is too long so here is the link for the github repo - Mohamud
If this is the link, you should replace use Validator; with this use Illuminate\Support\Facades\Validator as Validator - Ahmad Rezk

1 Answers

1
votes

I had the same problem cropped up while trying to post a discussion. What I did was to remove the type-hint from the constructor (in vendor/devdojo/chatter/src/Events/ChatterBeforeNewDiscussion.php) like so public function __construct(Request $request, $validator) { $this->request = $request; $this->validator = $validator; }

and also changed the Event::fire(new ChatterBeforeNewDiscussion($request, $validator)); to Event::dispatch(new ChatterBeforeNewDiscussion($request, $validator));

(in vendor/devdojo/chatter/src/Controllers/ChatterDiscussionController.php)

I was then able to post discussions seamlessly!