63318358

Date: 2020-08-08 18:36:45
Score: 4.5
Natty:
Report link

It's solved but without eager loading and using LEFT JOIN, if anyone could help me changed to eager loading please answer

 $model = DB::table('orders')
                ->select('orders.*','order_products.*','order_vps_customs.*')
                ->join('order_products','orders.id','=','order_products.order_id','left')
                ->join('order_vps_customs','orders.id','=','order_vps_customs.order_id','left')
                ->get();

        // dd($model->toArray());
        $dTable = DataTables()->of($model)->addIndexColumn()
            ->editColumn('package',function($data){
                
                $package = $data->product_name;
                if (empty($data->product_name)) 
                {
                    $package = $data->package;
                }

                return $package;
            })
            ->editColumn('registered_at',function($data){
                return date('d, M Y',strtotime($data->created_at));
            })
            ->editColumn('due_date',function($data){
                return date('d, M Y', strtotime("+".$data->duration." year",strtotime($data->created_at)));
            })
            ->editColumn('duration',function($data){
                return $data->duration." Tahun";
            })
            ->editColumn('total',function($data){
                return "-";
            })
            ->editColumn('status',function($data){
                $html = '';
                if ($data->status == 'pending') 
                {
                    $html = '<label class="badge badge-secondary">Pending</label>';
                }
                else if ($data->status == 'aktif') 
                {
                    $html = '<label class="badge badge-success">Aktif</label>';
                }
                else
                {
                    $html = '<label class="badge badge-warning">Non - Aktif</label>';
                }

                return $html;
            })
            ->rawColumns(['status']);

        return $dTable->make(true);
Reasons:
  • Blacklisted phrase (1.5): help me
  • RegEx Blacklisted phrase (1.5): please answer
  • RegEx Blacklisted phrase (2): anyone could help me
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: 0x00b0