[英]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.目标:我想将
autograph
数据库数据从AutographController.php
传递给ImageUploadController.php
基本上是为了确定数据库中是否已经存在数据。
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 Facade\Ignition\Exceptions\ViewException
Class 'App\Http\Controllers\Autograph' not found (View: C:\xampp\htdocs\PKL_DSV\resources\views\imageUpload.blade.php) Class 'App\Http\Controllers\Autograph' 未找到(查看:C:\xampp\htdocs\PKL_DSV\resources\views\imageUpload.blade.php)
i already imported use App\Http\Controllers\AutographController;
我已经导入了
use App\Http\Controllers\AutographController;
you have to import your model by adding use App\Autograph
not use App\Http\Controllers\AutographController
您必须通过添加
use App\Autograph
not use App\Http\Controllers\AutographController
来导入 model
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.
如果您必须传递数据,您可以使用会话并在使用后刷新会话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.