我最近升级到5.4并且我从传递id并加载记录,到将订单对象直接传递给show函数。我在几个新安装的项目中使用这种方法,所以我想也许它与升级有关。另外,我在我的InvoicesController上尝试了同样的结果。
我的订单路线:
Route::resource('order', 'OrderController');
以下是OrderController的摘录:
namespace App\Http\Controllers;
use App\Order;
use App\User;
use App\Item;
use Illuminate\Http\Request;
use Illuminate\Routing\Controllers;
use App\Http\Requests\OrderRequest;
class OrderController extends Controller {
public function show(Order $order)
{
dd($order);
}
}
虽然dd返回了这个 - 没有数据:
Invoice {#738 ▼
#table: "invoices"
+timestamps: true
#dates: array:1 [▶]
#connection: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: false
+wasRecentlyCreated: false
#attributes: []
#original: []
#casts: []
#dateFormat: null
#appends: []
#events: []
#observables: []
#relations: []
#touches: []
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
#forceDeleting: false
}
答案 0 :(得分:0)
确保您的HTML如下:
<a href="{{ route('order.show',$your_order_id) }}">show</a>
控制器:
public function show(Order $order)
{
dd($order);
}
或
public function show(\App\Order $order)
{
dd($order);
}
希望有所帮助