public function create() { $data = Input::all(); $promo = new Promo(); $promo->days = Input::get('days'); $promo->code = Crypt::encrypt(Input::get('code')); $promo->status = 0; $promo->colony_id = Input::get('colony_id'); if ($promo->save()) { $user_id = Input::get('admin_colonia'); $admin_user = DB::connection('habitaria_dev')->select('select email from users where id = ? ', [$user_id]); foreach ($admin_user as $user) { $admin_email = $user->email; } $admin_neighbor = Neighbors::where('user_id', '=', $user_id)->first(); $colony_data = Colony::where('id', '=', $promo->colony_id)->first(); $colony_name = $colony_data->name; $data = array('email' => $admin_email, 'days' => $promo->days, 'code' => Crypt::decrypt($promo->code), 'colony' => $colony_name, 'admin' => $admin_neighbor->name . ' ' . $admin_neighbor->last_name); Mail::send('emails.cupon_promo', $data, function ($message) use($admin_email) { $message->subject('Promo de HABITARIA'); $message->to($admin_email); }); $notice_msg = 'Promo enviada al administrador de la Colonia: ' . $colony_name; return Redirect::action('PromoController@report_promo', $promo->colony_id)->with('error', false)->with('msg', $notice_msg)->with('class', 'info'); } }