Answer the question
In order to leave comments, you need to log in
How to save data from another controller in Laravel?
when adding an ad in the store(Request $request) method,
I check for authorization
if(!Auth::check()){
Cookie::queue('ads_request',json_encode($request->input()), time() + 3600 * 24 * 30 * 365);
return redirect()->route('login');
}
$ads = new AdsController;
$ads->store(json_decode(Cookie::get('ads_request')));
Type error: Argument 1 passed to App\Http\Controllers\AdsController::store() must be an instance of Illuminate\Http\Request, instance of stdClass given, called in /home/vagrant/projects/Laravel/mosdogs/app/Http/Controllers/Auth/LoginController.php on line 83
Answer the question
In order to leave comments, you need to log in
Never initialize controller classes, they are not for that.
You need to make a separate class - service and use its method in both controllers. Well, or at least a trait.
Calling controller methods is bad in most cases and should indicate that something is wrong in your application.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question