如何在 LARAVEL 中将值从一个控制器传递到另一个控制器?
How to pass value from one controller to another in LARAVEL?
GOALS: 我想将 autograph
数据库数据从 AutographController.php
传递到 ImageUploadController.php
基本上是为了确定数据是否已经存在于数据库。
我做了什么:
if (Autograph::where("$autograph", '=', Input::get('autograph'))->exists()) {
echo "Autograph Registered.";
}
但是它给我这个错误
Facade\Ignition\Exceptions\ViewException
Class 'App\Http\Controllers\Autograph' 未找到(查看:C:\xampp\htdocs\PKL_DSV\resources\views\imageUpload.blade.php)
我已经导入了use App\Http\Controllers\AutographController;
您必须通过添加 use App\Autograph
而不是 use App\Http\Controllers\AutographController
来导入您的模型
试试这个,
App\Autograph::where("$autograph", '=', Input::get('autograph'))
并确保使用正确的命名空间。另外,不要在控制器之间传递数据,使用模型做任何你想做的事。如果一定要传数据,可以使用session,使用后flush session
GOALS: 我想将 autograph
数据库数据从 AutographController.php
传递到 ImageUploadController.php
基本上是为了确定数据是否已经存在于数据库。
我做了什么:
if (Autograph::where("$autograph", '=', Input::get('autograph'))->exists()) {
echo "Autograph Registered.";
}
但是它给我这个错误
Facade\Ignition\Exceptions\ViewException
Class 'App\Http\Controllers\Autograph' 未找到(查看:C:\xampp\htdocs\PKL_DSV\resources\views\imageUpload.blade.php)
我已经导入了use App\Http\Controllers\AutographController;
您必须通过添加 use App\Autograph
而不是 use App\Http\Controllers\AutographController
试试这个,
App\Autograph::where("$autograph", '=', Input::get('autograph'))
并确保使用正确的命名空间。另外,不要在控制器之间传递数据,使用模型做任何你想做的事。如果一定要传数据,可以使用session,使用后flush session