Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $emailstat = new Emailstat();
     $timestamp = new Carbon();
     $date = $timestamp->createFromTimeStamp($request->input('timestamp'))->toDateString();
     $domain = $request->input('domain');
     $event = $request->input('event');
     if ($emailstat->where('date', '=', $date)->where('domain', '=', $domain)->where('event', '=', $event)->exists()) {
         $emailstat = $emailstat->where('date', '=', $date)->where('domain', '=', $domain)->where('event', '=', $event)->first();
         $emailstat->count += 1;
         $emailstat->save();
     } else {
         $emailstat->event = $event;
         $emailstat->domain = $domain;
         $emailstat->count = 1;
         $emailstat->date = $date;
         $emailstat->save();
     }
 }
Example #2
0
 /**
  * @return mixed
  */
 public function getEmailDeliveryChart()
 {
     $dataTableRows = Emailstat::select(DB::raw('date,
         SUM(CASE WHEN event="bounced" THEN count END) as bounced,
         SUM(CASE WHEN event="complained" THEN count END) as complained,
         SUM(CASE WHEN event="dropped" THEN count END) as dropped,
         SUM(CASE WHEN event="delivered" THEN count END) as delivered'))->groupby('date')->orderby('date', 'desc')->take(100)->get();
     $dataTableColumns = [['date', 'Date'], ['number', 'Bounced'], ['number', 'Complained'], ['number', 'Dropped'], ['number', 'Delivered']];
     $name = 'emaildel';
     $title = 'Message Delivery';
     $dateFormat = 'Y-m-d';
     $isStacked = true;
     return (new Chart\ColumnChartController())->createColumnChart($name, $title, $dataTableColumns, $dataTableRows, $dateFormat, $isStacked);
 }