findFirst("email = '{$post['email']}'"); $event_info = new \eventInfo(); if(isset($post['event']) && !empty($post['event'])) { $event_info->event_id = $data->id; $event_info->customer_id = $customers->id; $event_info->project_id = $post['project_id']; if($data->unique) { $unique = $event_info->findFirst("event_id = {$data->id} AND customer_id = {$customers->id} AND project_id = {$post['project_id']}"); if($unique) { throw new \Exception(); } } $MyMailer = new EventMailer(); $MyMailer->setFromName($post['project_name']); $MyMailer->SendDelivery($template->toArray(),$data->toArray(),array($customers->toArray())); $event_info->save(); } else { throw new \Exception(); } } else { throw new \Exception("email missing"); } } }