0

我存储在那里的第一个表“Offers”提供了详细信息。如果提供状态 = 公开,那么每个能够访问和状态的人都将在 Yajra 数据表中显示为“已批准”。

否则,如果提供状态 = 请求,则用户可以请求访问。当他们提交访问请求时,它将以用户 ID 和报价 ID 存储在 Offer Request 表中,并且 status = 0 表示处于 yajra 数据表状态待处理。然后管理员可以在 yajra 数据表状态中设置状态 = 1 表示批准。

我在此代码中收到此错误。

注意:抱歉英语不好

->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;

            })
4

1 回答 1

2

我认为你应该为 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;

        })

试试看!

于 2019-11-21T07:45:51.090 回答