我正在尝试运行下面的查询,但是我始终获得空返回。
$result = Order::with(['customers', 'team'])->where('customers_id','=', $custid)->select(sprintf('%s.*', (new Order)->table));然后我把它改成
$result = Order::with(['customers', 'team'])->where(function($query) use ($cust) {$query->where('customers_id', $cust);})->select(sprintf('%s.*', (new Order)->table));仍然返回null。
customers_id属于orders表,并引用客户的表。我正在从$custid参数中获取这个URL。
如果我用整数(例如3 )替换$custid,它会用id 3返回客户的所有订单。我花了几个小时试图解决这个问题。我曾经主持过Heroku和localhost,但是什么都没有。
发布于 2020-05-21 03:39:13
您的问题在于获取url参数的方式。将url参数放入方法声明中。
检查依赖注入下的Laravel文档&路由参数 这里
public function index(Request $request, $custid) {
https://stackoverflow.com/questions/61926465
复制相似问题