Bayu Poggers
Bayu Poggers

Reputation: 15

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;

Upvotes: 0

Views: 96

Answers (2)

Ali Raza
Ali Raza

Reputation: 192

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.

Upvotes: 1

IBRAHIM EZZAT
IBRAHIM EZZAT

Reputation: 983

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

Upvotes: 2

Related Questions