Advertisement
Guest User

Controller

a guest
May 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. public function index($id)
  2.     {
  3.         $thisYears = date('Y');
  4.         $thisMonth = date('m');
  5.  
  6.         $produk = Product::findOrFail($id);
  7.         $transaksi = Transaction::where('product_id', $produk->id)
  8.                      ->where('created_at', 'LIKE','%'.$thisYears.'%')
  9.                      // ->Where('status','!=','Menunggu')
  10.                      ->get();
  11.         $totalTrans = $transaksi->count();
  12.  
  13.  
  14.         /*Date*/
  15.         $months = array(1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni', 7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember');
  16.         $transposed = array_slice($months, date('n'), 12, true) + array_slice($months, date('n'), true);
  17.         $last8 = array_reverse(array_slice($transposed, -8, 12, true), true);
  18.         return view('admin.product.insight.index', compact('transaksi','totalTrans','thisMonth','months','transposed','last8'));
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement