简体   繁体   中英

How to pass value from one controller to another in LARAVEL?

GOALS: I want to pass autograph database data to ImageUploadController.php from AutographController.php basically to determine if the data already existed in the Database.


What I've Done:

if (Autograph::where("$autograph", '=', Input::get('autograph'))->exists()) {
echo "Autograph Registered.";
}

But it's giving me this error

Facade\Ignition\Exceptions\ViewException

Class 'App\Http\Controllers\Autograph' not found (View: C:\xampp\htdocs\PKL_DSV\resources\views\imageUpload.blade.php)

i already imported use App\Http\Controllers\AutographController;

you have to import your model by adding use App\Autograph not use App\Http\Controllers\AutographController

Try this,

App\Autograph::where("$autograph", '=', Input::get('autograph'))

and make sure to use correct namespace. Also, do not pass data between controllers, use models to do whatever you want. If you've to pass data, you can use sessions and flush sessions after use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM