我使用的是Laravel 5.2。我只是想简单地重定向到路由名products
。但是它发送了一个错误
BindingResolutionException in Container.php line 835:
Unresolvable dependency resolving [Parameter #0 [ <required> $url ]] in class Symfony\Component\HttpFoundation\RedirectResponse
我的控制器看起来像
<?php
namespace App\Http\Controllers\Backend;
use Illuminate\Http\Request;
use App\Models\Product as ProductModel;
use Illuminate\Http\RedirectResponse as Redirect;
use App\Repositories\Products as ProductsRepository;
class ProductsController extends Controller
{
public function addProduct(Request $request, Redirect $redirect)
{
//do some stuff
return $redirect->route('products');
}
}
我正在做一个简单的重定向。我认为它期待一个参数。但无法解决。任何帮助将不胜感激。
答案 0 :(得分:0)
请尝试以下方法:
return redirect()->route('products');