我存储的第一个表"Offers"提供了详细信息。如果offer status=public,那么所有能够访问的人和状态都将在Yajra数据表中显示为"Approved"。
否则,如果offer status=request,则用户可以请求访问。当他们提交访问请求时,它将存储在Offer Request表中,其中包含用户id和Offer id,状态=0表示在yajra数据表中处于挂起状态。然后管理员可以在yajra数据表中设置status=1 mean status approve。
我在这个代码中得到了这个错误。
NB:抱歉英语不好
->editColumn('status', function(Offer $offer) {
if($offer->offer_permission == 'public')
{
$status = '<span class="badge badge-primary">Approve</span>';
}elseif($offer->offer_permission == 'request')
{
$checkstatus= OfferRequest::select('status')->where('offer_id', $offer->id )->where('user_id', Auth::id())->pluck('status')->toArray();
if($checkstatus['status'] == 0)
{
$status = '<span class="badge badge-secondary">Pending</span>';
}elseif ($checkstatus['status'] == '1')
{
$status = '<span class="badge badge-primary">Approve</span>';
}elseif ($checkstatus['status'] == '2')
{
$status = '<span class="badge badge-danger">Rejected</span>';
}elseif ($checkstatus['status'] == '3')
{
$status = '<span class="badge badge-danger">Blocked</span>';
}else
{
$status = '<a href="' . route('offers.show', $offer->id) .'"><span class="badge badge-secondary">Apply Now</span></a>';
}
}
return $status;
})
我认为应该为checkstatus变量添加检查点,不管它是否为空。
editColumn('status', function(Offer $offer) {
if($offer->offer_permission == 'public')
{
$status = '<span class="badge badge-primary">Approve</span>';
}elseif($offer->offer_permission == 'request')
{
$checkstatus= OfferRequest::select('status')->where('offer_id', $offer->id )->where('user_id', Auth::id())->pluck('status')->toArray();
if(empty($checkstatus)){
if($checkstatus['status'] == 0)
{
$status = '<span class="badge badge-secondary">Pending</span>';
}elseif ($checkstatus['status'] == '1')
{
$status = '<span class="badge badge-primary">Approve</span>';
}elseif ($checkstatus['status'] == '2')
{
$status = '<span class="badge badge-danger">Rejected</span>';
}elseif ($checkstatus['status'] == '3')
{
$status = '<span class="badge badge-danger">Blocked</span>';
}else
{
$status = '<a href="' . route('offers.show', $offer->id) .'"><span class="badge badge-secondary">Apply Now</span></a>';
}
}else{
$status = '<a href="' . route('offers.show', $offer->id) .'"><span class="badge badge-secondary">Apply Now</span></a>';
}
}
return $status;
})
试试看!