/** * @param Request $request * @return mixed */ public function postMaillist(Request $request) { $formData = ['email' => $request->get('email')]; $rules = ['email' => 'required|email|unique:maillist,email']; $validation = Validator::make($formData, $rules); if ($validation->fails()) { return Redirect::action('MaillistController@getMaillist')->withErrors($validation)->withInput(); } $maillist = new Maillist(); $maillist->email = $formData['email']; $maillist->save(); Flash::info('success'); return Redirect::action('HomeController@index'); }
/** * @return mixed */ public function postMaillist() { $formData = array('email' => Input::get('email')); $rules = array('email' => 'required|email|unique:maillist,email'); $validation = Validator::make($formData, $rules); if ($validation->fails()) { return Redirect::action('MaillistController@getMaillist')->withErrors($validation)->withInput(); } $maillist = new Maillist(); $maillist->email = $formData['email']; $maillist->save(); //Notification::success('success'); return Redirect::action('HomeController@index'); }
public function store() { $inputs = []; foreach (Input::all() as $key => $input) { if ($key == 'password' || $key == 'password_confirmation') { $inputs[$key] = $input; } else { $inputs[$key] = Jamesy\Sanitiser::trimInput($input); } } $validation = Jamesy\MyValidations::validate($inputs, array_merge(Setting::$rules, User::$rules)); if ($validation != NULL) { return Response::json($validation); } else { $setup = new Setting(); $setup->sitename = Input::get('sitename'); $setup->save(); $maillist = new Maillist(); $maillist->name = "General"; $maillist->save(); $tag = new Tag(); $tag->name = "Test Emails"; $tag->save(); try { $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password_confirmation'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true); $group = Sentry::createGroup(['name' => 'Administrator']); $group = Sentry::createGroup(['name' => 'Publisher']); $group = Sentry::findGroupByName('Administrator'); $user->addGroup($group); return Response::json(["success" => "It's all ready! You are being redirected to the login page...", "url" => URL::to('dashboard/login')]); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { return Response::json(["email" => "Email is required."]); } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { return Response::json(["password" => "Password is required."]); } catch (Cartalyst\Sentry\Users\UserExistsException $e) { return Response::json(["email" => "Email is already taken."]); } } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Maillist the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Maillist::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function bulk_destroy() { $listIds = Input::get('lists'); Maillist::whereIn('id', $listIds)->delete(); return Redirect::to('dashboard/lists')->withSuccess(count($listIds) . ' ' . str_plural('list', count($listIds)) . ' destroyed.'); }
public function import() { $validation = Jamesy\MyValidations::validate(Input::all(), $this->fileRules); if ($validation != NULL) { return Redirect::back()->withErrors($validation); } else { $input = Input::file('file'); $ext = pathinfo($input->getClientOriginalName(), PATHINFO_EXTENSION); if ($ext != 'xlt' && $ext != 'xls' && $ext != 'csv') { return Redirect::back()->withIssues('You attempted the import with an invalid file. File must be Excel or CSV'); } else { $import = new Jamesy\Imports($input, $this->rules); $importResult = $import->getInsertArray(); if (is_array($importResult)) { $totalNum = $importResult[0]; $duplicatesNum = $importResult[1]; $passedArr = $importResult[2]; $passedNum = count($passedArr); $failedNum = (int) $totalNum - (int) $duplicatesNum - (int) $passedNum; $timestamp = $importResult[3]; if (count($passedArr)) { Subscriber::insert($passedArr); $list = Maillist::find(1); $list->touch(); $subscribers = Subscriber::where('created_at', $timestamp)->where('updated_at', $timestamp)->get(); foreach ($subscribers as $key => $subscriber) { $list->subscribers()->attach($subscriber->id); } } $message = "<b>{$totalNum}</b> " . str_plural('row', $totalNum) . " found in excel file."; if ($duplicatesNum) { $message .= "<br /><b>{$duplicatesNum}</b> had duplicate email addresses."; } if ($passedNum == 1) { $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and was stored."; } else { $message .= "<br /><b>{$passedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and were stored."; } if ($failedNum == 1) { $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and was NOT stored."; } elseif ($failedNum > 1) { $message .= "<br /><b>{$failedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and were NOT stored."; } return Redirect::back()->withSuccess($message); } else { return Redirect::back()->withIssues($importResult); } } } }
public function edit_draft($id) { $email_configs = ['from_name' => Setting::getFromName($this->user), 'from_email' => Setting::getFromEmail($this->user), 'reply_to_email' => Setting::getReplyToEmail($this->user)]; $tag_list = Tag::getTagList(); $subscribers = Subscriber::getSubscribersForEmail(); $subsArr = []; foreach ($subscribers as $subscriber) { $subsArr[$subscriber->email] = $subscriber->first_name . ' ' . $subscriber->last_name . '(' . $subscriber->email . ')'; } $maillists = Maillist::getMaillistsForEmail(); $listsArr = []; foreach ($maillists as $maillist) { $listsArr[$maillist->id] = $maillist->name . ' (' . count($maillist->subscribers) . ' subscribers)'; } $email = Draft::find($id); return View::make('backend.emails.edit-draft', ['user' => $this->user, 'isAdmin' => $this->isAdmin, 'configs' => $this->configs, 'logged_in_for' => $this->logged_in_for, 'activeParent' => $this->activeParent, 'active' => 'createemails', 'subscribers' => $subsArr, 'mail_lists' => $listsArr, 'email_configs' => $email_configs, 'tag_list' => $tag_list, 'email' => $email]); }