我想通过产品展示方法使用登录的用户ID和拍卖ID向投标表提交数据。
这就是我的表之间的关系。
使用ProductController很好,还是应该为出价表创建另一个控制器?
产品展示刀片
@extends('layouts.app')
@section('content')
<div class="container">
<div class="my-3 border">
<div class="row">
<div class="col-md-5">
<img src="/storage/images/{{$product->image}}" alt="" style="width: 100%;">
</div>
<div class="col-md-7">
<h2>{{$product->name}}</h2>
<p>{{$product->description}}</p>
<span>Category: {{$product->category->name}}</span><br>
<span class="text-right">Auction Ends: {{$product->auction->deadline}}</span>
<div class="price">Initial Price: {{$product->price}}</div>
{!! Form::open(['action' => 'BiddingsController@create', 'method' => 'POST', 'enctype' => 'multipart/form-data']) !!}
<div class="form-inline">
{{Form::number('bidamount', '',['class' => 'form-control mr-1', 'placeholder' => 'Place your bid'])}}
{{Form::submit('Place Bid', ['class' => 'btn btn-primary'])}}
</div>
{!! Form::close() !!}
@endsection
在Laravel 6应用中,您可以使用auth()
帮助器获取“已登录”用户。
$authUser = auth()->user();
文档:https://laravel.com/docs/6.x/helpers#method-auth
Cordially