/** * @author: lmkhang (skype) * @date: 2016-01-15 * Action: Admin login */ public function login(Request $request) { //check islogged if ($this->isLoggedAdmin()) { //set Flash Message $this->setFlash('message', 'Logged!'); return Redirect::intended('/adminntw')->with('message', 'Logged!'); } $post = $request->all(); $info = $this->trim_all($post['login']); //Setup validation $validator = Validator::make($info, ['account' => 'required|min:5|max:100', 'password' => 'required|min:5|max:50']); //Checking if ($validator->fails()) { // The given data did not pass validation //set Flash Message $this->setFlash('message', 'Errors!'); return redirect()->back(); } $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; $pwd = $this->encryptString($info['password'], $salt); $admin_get = new \App\Admin(); $admin = $admin_get->checkAccount($info['account'], $pwd); //set Session if (!$admin) { //set Flash Message $this->setFlash('message', 'This account is not available!'); return redirect()->back()->with('message', 'This account is not available!'); } //set Session $this->setLogSession($admin->toArray()); //set Flash Message $this->setFlash('message', 'Login successfully!'); return Redirect::intended('/adminntw')->with('message', 'Login successfully!'); }
public function __construct() { $static_config = config('payment'); $static_config['UrlOK'] = url($static_config['UrlOK']); $static_config['UrlKO'] = url($static_config['UrlKO']); $static_config['MerchantURL'] = url($static_config['MerchantURL']); $dinamic_config = unserialize(Config::where('name', '=', 'redsys')->firstOrFail()->data); $options = array_merge($static_config, $dinamic_config); return $this->setOption($options); }
public function set($key, $value = '') { $param = Config::where('key', $key)->first(); if ($param) { $param->value = $value; $param->save(); return true; } else { return false; } }
protected function saveConfigs() { foreach ($this->configs as $key => $value) { $config = Config::where('key', '=', $key)->first(); if ($config == null) { $config = new Config(); } $config->key = $key; $config->value = $value; $config->save(); } }
/** * @author: lmkhang - skype * @date: 2016-01-15 * Member detail */ public function detail($user_id) { //set Title for PAGE $this->_page_title = 'Members'; //check user id existed $user_get = new \App\User(); $user = $user_get->getAccount($user_id); if (!$user) { //set Flash Message $this->setFlash('message', 'The user is not existed!'); return Redirect::intended($this->_page_url)->with('message', 'The user is not existed!'); } //Get income-expenditure list $user_in_ex_get = new \App\UserIncomeExpenditure(); $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value']; $user_in_ex = $user_in_ex_get->getAllPaging(['user_income_expenditure.user_id' => $user_id, 'user_income_expenditure.status' => 1], $number_pagination); return view('admin.members.detail', ['admin' => $this->_admin, 'name' => $user['full_name'] ? $user['full_name'] : $user['first_name'] . ' ' . $user['last_name'], 'page_title' => $this->_page_title, 'active' => $this->_active, 'number_pagination' => $number_pagination, 'user' => $user, 'user_in_ex' => $user_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'in_exp_action' => config('constant.in_exp_action')]); }
/** * @author: lmkhang - skype * @date: 2016-01-09 * DASHBOARD HOME */ public function index() { //Check Status if ($this->_stop) { return Redirect::intended(url($this->_redirectTo)); } //set Title for PAGE $this->_page_title = 'Home'; //Get income-expenditure list $user_in_ex_get = new \App\UserIncomeExpenditure(); $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value']; $user_in_ex = $user_in_ex_get->getAllPaging(['user_id' => $this->_user_id, 'status' => 1], $number_pagination); //get money $user_stats_get = new \App\UserStats(); $user_stats = $user_stats_get->getAccount($this->_user_id); //min PAY $minpay = \App\Config::where(['prefix' => 'payment', 'name' => 'minpay', 'del_flg' => 1])->get()[0]['value']; return view('dashboard.home.index', ['user' => $this->_user, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'user_stats' => $user_stats, 'number_pagination' => $number_pagination, 'user_in_ex' => $user_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'in_exp_action' => config('constant.in_exp_action'), 'minpay' => $minpay]); }
/** * @author: lmkhang - skype * @date: 2016-01-15 * DASHBOARD HOME */ public function index(Request $request) { //set Title for PAGE $this->_page_title = 'Home'; //get $gets = $request->all(); $gets = $this->trim_all($gets); $filter = isset($gets['filter']) ? $gets['filter'] : []; //unset if dont choose $filter_temp = $filter; foreach ($filter_temp as $k => $v) { if (!$v) { unset($filter[$k]); } } $filter['del_flg'] = 1; $filter['status'] = 1; //Get income-expenditure list $user_get = new \App\User(); $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value']; $user_in_ex = $user_get->getAllPaging($filter, $number_pagination); //get info payment $currency = \App\Config::where(['prefix' => 'payment', 'name' => 'currency', 'del_flg' => 1])->get()[0]['value']; $tax_pay_bank = \App\Config::where(['prefix' => 'payment', 'name' => 'tax_pay_bank', 'del_flg' => 1])->get()[0]['value']; //get Stats $home_get = new \App\Home(); $gross_amount = $home_get->getKey(['prefix' => 'stats', 'name' => 'gross_amount', 'del_flg' => 1])->value; $net_mount = $home_get->getKey(['prefix' => 'stats', 'name' => 'net_mount', 'del_flg' => 1])->value; $pay_amount = $home_get->getKey(['prefix' => 'stats', 'name' => 'pay_amount', 'del_flg' => 1])->value; $blocked_mount = $home_get->getKey(['prefix' => 'stats', 'name' => 'blocked_mount', 'del_flg' => 1])->value; $hold_amount = $home_get->getKey(['prefix' => 'stats', 'name' => 'hold_amount', 'del_flg' => 1])->value; $paid_amount = $home_get->getKey(['prefix' => 'stats', 'name' => 'paid_amount', 'del_flg' => 1])->value; $home = ['gross_amount' => $gross_amount, 'net_mount' => $net_mount, 'pay_amount' => $pay_amount, 'blocked_mount' => $blocked_mount, 'hold_amount' => $hold_amount, 'paid_amount' => $paid_amount]; //get user list $users = $user_get->getAllPaging(['status' => 1, 'del_flg' => 1]); return view('admin.home.index', ['admin' => $this->_admin, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'user_in_ex' => $user_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'currency' => $currency, 'tax_pay_bank' => $tax_pay_bank, 'home' => $home, 'users' => $users]); }
/** * @author: lmkhang - skype * @date: 2016-02-15 * */ public function detail(Request $request) { //set Title for PAGE $this->_page_title = 'Receipts and Expenses'; //get $gets = $request->all(); $gets = $this->trim_all($gets); $filter = isset($gets['filter']) ? $gets['filter'] : []; //unset if dont choose $filter_temp = $filter; foreach ($filter_temp as $k => $v) { if (!$v) { unset($filter[$k]); } } //get user list $user_get = new \App\User(); $users = $user_get->getAllPaging(['status' => 1, 'del_flg' => 1, 'sign_contract' => 1]); //get all receipts and expenses $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value']; $receipt_expense_get = new \App\UserIncomeExpenditure(); $receipt_expense = $receipt_expense_get->getAllPaging($filter, $number_pagination); return view('admin.stats.detail', ['admin' => $this->_admin, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'users' => $users, 'filter' => $filter, 'number_pagination' => $number_pagination, 'receipt_expense' => $receipt_expense, 'in_expen_type' => config('constant.in_expen_type'), 'in_expen_status' => config('constant.in_expen_status'), 'in_exp_action' => config('constant.in_exp_action')]); }
/** * @author: lmkhang - skype * @date: 2016-01-18 * Change payment (bank or paypal) */ public function payment_change(Request $request) { //Check Status if ($this->_stop) { return Redirect::intended(url($this->_redirectTo)); } //Get STATE of PAYMENT $payment_state = \App\Config::where(['prefix' => 'payment', 'name' => 'lock', 'del_flg' => 1])->get()[0]['value']; if ($payment_state == 1) { //Locked $this->setFlash('message', 'Cannot edit your payment while paying. This feature is locked temporarily.'); return redirect()->back(); } //Post $post = $request->all(); $payment = $post['payment']; //Trim $payment = $this->trim_all($payment); //get method $payment_method = config('constant.payment_method'); $method = $payment['method']; $arr_check = []; //Bank if ($method == 1) { $arr_check = ['bank' => 'required', 'number_bank' => 'required|min:5|max:50', 'first_name' => 'required|min:2|max:50', 'last_name' => 'required|min:2|max:50', 'address' => 'required|min:1|max:250', 'ward' => 'required|min:1|max:250', 'district' => 'required|min:1|max:250', 'city' => 'required|min:2|max:250', 'phone' => 'required|min:9|max:14', 'contact_email' => 'required|min:5|max:100|email']; } else { if ($method == 2) { $arr_check = ['paypal_email' => 'required|min:5|max:100|email']; } } //Setup validation $validator = Validator::make($payment, $arr_check); //Checking if ($validator->fails()) { //set Flash Message // $this->setFlash('errors', $validator->errors()->toArray()); $this->setFlash('message', 'Please type all information correctly for your payment method! <' . $payment_method[$method] . '>'); return redirect()->back(); } //Insert or Update $payment_get = new \App\Payment(); $payment_obj = $payment_get->getPaymentInfomation($this->_user_id); if (!$payment_obj) { $payment_obj = $payment_get; $payment_obj->user_id = $this->_user_id; } $payment_obj->payment_method = $method; if ($method == 1) { //Bank $payment_obj->bank_id = $payment['bank']; $payment_obj->id_number_bank = $payment['number_bank']; $payment_obj->phone = $payment['phone']; $payment_obj->last_name = $payment['last_name']; $payment_obj->mid_name = isset($payment['mid_name']) ? $payment['mid_name'] : ''; $payment_obj->first_name = $payment['first_name']; $payment_obj->address = $payment['address']; $payment_obj->ward = $payment['ward']; $payment_obj->district = $payment['district']; $payment_obj->city = $payment['city']; $payment_obj->contact_email = $payment['contact_email']; } else { if ($method == 2) { //Paypal $payment_obj->paypal_email = $payment['paypal_email']; } } $payment_obj->save(); //set Flash Message $this->setFlash('message', 'Update payment method <' . $payment_method[$method] . '> successfully!'); return redirect()->back()->with('message', 'Update payment method <' . $payment_method[$method] . '> successfully!'); }
public function step2Editor(Product $productsModel, Extra $extraModel) { $tpl = 0; $circulation = CartsCirculation::where('active', '=', 1)->where('alias', '=', 'vizitki')->get(); $kurs = Config::where('title', '=', 'kurs')->firstOrFail(); $products = $productsModel->getProd(); $extra = $extraModel->getExtra(); $service = Service::where('alias', '=', 'vizitki')->firstOrFail(); return view('order.template_editor_step2')->with('circulation', $circulation)->with('kurs', $kurs)->with('products', $products)->with('extra', $extra)->with('service', $service)->with('tpl', $tpl); }
/** * @author: lmkhang - skype * @date: 2016-02-05 * Get all amount of all user >= min pay */ public function getPayAmount() { //min PAY $minpay = \App\Config::where(['prefix' => 'payment', 'name' => 'minpay', 'del_flg' => 1])->get()[0]['value']; return \App\UserStats::whereRaw('status = ? AND del_flg = ? AND total >= ? ', [1, 1, $minpay])->sum('total'); }
/** * @author: lmkhang - skype * @date: 2016-02-01 * Detail about income and expenditure of channel */ public function detail($daily_channel_id) { //Check Status if ($this->_stop) { return Redirect::intended(url($this->_redirectTo)); } //set Title for PAGE $this->_page_title = 'Detail of A Channel'; //check owning channel $channel_get = new \App\Channels(); $_channel = $channel_get->getUserIdByChannelId($daily_channel_id); if (!$_channel || $_channel['user_id'] != $this->_user_id) { //set Flash Message $this->setFlash('message', 'You do not own that channel!'); return Redirect::intended($this->_page_url)->with('message', 'You do not own that channel!'); } //get income and expenditure list //Get income-expenditure list $channel_in_ex_get = new \App\ChannelIncome(); $number_pagination = \App\Config::where(['prefix' => 'site', 'name' => 'pagination', 'del_flg' => 1])->get()[0]['value']; $channel_in_ex = $channel_in_ex_get->getAllPaging(['channel_income.user_id' => $this->_user_id, 'channel_income.daily_channel_id' => $daily_channel_id], $number_pagination); return view('dashboard.channels.detail', ['user' => $this->_user, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'number_pagination' => $number_pagination, 'daily_channel_name' => $_channel['daily_channel_name'], 'channel_in_ex' => $channel_in_ex, 'in_expen_type' => config('constant.in_expen_type'), 'in_exp_action' => config('constant.in_exp_action')]); }
/** * @author: lmkhang - skype * @date: 2016-01-10 * Active sign contract */ public function activeSignContract($code) { //Check Status if ($this->_stop) { return Redirect::intended(url($this->_redirectTo)); } $hours = \App\Config::where(['prefix' => 'site', 'name' => 'active_expire', 'del_flg' => 1])->get()[0]['value']; $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; //Check valid $decryptString = ''; try { $decryptString = $this->ytb_decrypt($code, $salt); list($create_date, $confirm_payment_code, $emailGet) = explode('---', $decryptString); } catch (\Exception $e) { //set Flash Message $this->setFlash('message', 'The code is not valid!'); return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid!'); } if (!$decryptString || !$confirm_payment_code || !$emailGet) { //set Flash Message $this->setFlash('message', 'The code is not valid!'); return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid!'); } //Check Email is existed if ($this->_user->payment_email != $emailGet) { //set Flash Message $this->setFlash('message', 'The code is not match with email which had signed!'); return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not match with email which had signed contract!'); } //check code $now = time(); $compareTime = $now - $hours * 60 * 60; if ($this->_user->confirm_payment_code != $confirm_payment_code || $compareTime > $create_date) { //set Flash Message $this->setFlash('message', 'The code is not valid or expired!'); return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid or expired!'); } //check existed email $user_check_pm = new \App\User(); if ($user_check_pm->checkExistedPaymentEmail($this->_user_id, $this->_user->payment_email)) { //set Flash Message $this->setFlash('message', 'The payment email had been activated by other person!'); return Redirect::intended('/dashboard/sign_contract')->with('message', 'The payment email had been activated by other person!'); } //Good status $this->_user->sign_contract = 1; $this->_user->confirm_payment_code = ''; $this->_user->save(); //Send mail - congrats $this->_sendMailSignContractCongrats(); //set Flash Message $this->setFlash('message', $this->getName() . ' signed contract successfully: ' . $this->_user->payment_email); return Redirect::intended('/dashboard')->with('message', $this->getName() . ' signed contract successfully: ' . $this->_user->payment_email); }
/** * @author: lmkhang (skype) * @date: 2015-12-26 * * Home - Master */ public function index(Request $request) { $get = $request->all(); $refer = ''; if (isset($get['refer'])) { $refer = $get['refer']; $this->getFlash('refer'); $this->setFlash('refer', $refer); } else { $this->getFlash('refer'); $this->setFlash('refer', 'no_refer'); } //get FAQ list $faq_get = new \App\Faq(); $faq = $faq_get->getAll(['del_flg' => 1]); //Stats $home_get = new \App\Home(); $stats_show = $home_get->getAll(['prefix' => 'stats_show', 'del_flg' => 1]); //Preparing link for JOINING US $joinus = ['logged' => false, 'url_join' => '', 'url_logout' => '/logout']; //get Info of Site $description = \App\Config::where(['prefix' => 'site', 'name' => 'description', 'del_flg' => 1])->get()[0]['value']; $keywords = \App\Config::where(['prefix' => 'site', 'name' => 'keywords', 'del_flg' => 1])->get()[0]['value']; $skype = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'skype', 'del_flg' => 1])->get()[0]['value']; $fb = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'fb', 'del_flg' => 1])->get()[0]['value']; $google = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'google', 'del_flg' => 1])->get()[0]['value']; $pinterest = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'pinterest', 'del_flg' => 1])->get()[0]['value']; $twitter = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'twitter', 'del_flg' => 1])->get()[0]['value']; $tumblr = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'tumblr', 'del_flg' => 1])->get()[0]['value']; $dribbble = \App\Config::where(['prefix' => 'social_ntw', 'name' => 'dribbble', 'del_flg' => 1])->get()[0]['value']; $contact_email = \App\Config::where(['prefix' => 'site', 'name' => 'contact_email', 'del_flg' => 1])->get()[0]['value']; $site = ['description' => $description, 'keywords' => $keywords, 'contact_email' => $contact_email, 'urlhome' => config('app.url'), 'refer' => $refer, 'message' => $this->hasFlash('message') ? $this->getFlash('message') : '']; $socialntw = ['skype' => $skype, 'fb' => $fb, 'google' => $google, 'pinterest' => $pinterest, 'twitter' => $twitter, 'tumblr' => $tumblr, 'dribbble' => $dribbble]; $daily = ['url_join' => '']; $fbook = ['url_join' => '', 'url_callback' => '', 'api_key' => '']; $google = ['url_join' => '']; //Check Logged if ($this->isLogged()) { $joinus['logged'] = true; } else { //get Info of Dailymotion's API $daily['api_key'] = \App\Config::where(['prefix' => 'daily', 'name' => 'api_key', 'del_flg' => 1])->get()[0]['value']; $daily['url_callback'] = \App\Config::where(['prefix' => 'daily', 'name' => 'url_callback', 'del_flg' => 1])->get()[0]['value']; // $daily['url_join'] = 'http://www.dailymotion.com/logout?urlback=' . urlencode(str_replace(array('{API_KEY}', '{URL_CALLBACK}'), array($daily['api_key'], $site['urlhome'] . $daily['url_callback']), \App\Config::where(['prefix' => 'daily', 'name' => 'url_join', 'del_flg' => 1])->get()[0]['value'])); $daily['url_join'] = str_replace(array('{API_KEY}', '{URL_CALLBACK}'), array($daily['api_key'], $site['urlhome'] . $daily['url_callback']), \App\Config::where(['prefix' => 'daily', 'name' => 'url_join', 'del_flg' => 1])->get()[0]['value']); //get Info of FB's API $fbook['api_key'] = \App\Config::where(['prefix' => 'fb', 'name' => 'api_key', 'del_flg' => 1])->get()[0]['value']; $fbook['api_secret'] = \App\Config::where(['prefix' => 'fb', 'name' => 'api_secret', 'del_flg' => 1])->get()[0]['value']; $fbook['scope'] = \App\Config::where(['prefix' => 'fb', 'name' => 'scope', 'del_flg' => 1])->get()[0]['value']; $fbook['url_callback'] = \App\Config::where(['prefix' => 'fb', 'name' => 'url_callback', 'del_flg' => 1])->get()[0]['value']; $fb = new Facebook(['app_id' => $fbook['api_key'], 'app_secret' => $fbook['api_secret']]); $helper = $fb->getRedirectLoginHelper(); $permissions = explode(',', $fbook['scope']); // Optional permissions $fbook['url_join'] = htmlspecialchars($helper->getLoginUrl(config('app.url') . $fbook['url_callback'], $permissions)); //get Info of Google's API $google['api_key'] = \App\Config::where(['prefix' => 'google', 'name' => 'api_key', 'del_flg' => 1])->get()[0]['value']; $google['client_id'] = \App\Config::where(['prefix' => 'google', 'name' => 'client_id', 'del_flg' => 1])->get()[0]['value']; $google['client_secret'] = \App\Config::where(['prefix' => 'google', 'name' => 'client_secret', 'del_flg' => 1])->get()[0]['value']; $google['scope'] = \App\Config::where(['prefix' => 'google', 'name' => 'scope', 'del_flg' => 1])->get()[0]['value']; $google['url_callback'] = \App\Config::where(['prefix' => 'google', 'name' => 'url_callback', 'del_flg' => 1])->get()[0]['value']; $client_id = $google['client_id']; $client_secret = $google['client_secret']; $redirect_uri = config('app.url') . $google['url_callback']; $simple_api_key = $google['api_key']; //Create Client Request to access Google API $client = new \Google_Client(); $client->setApplicationName("PHP Google OAuth Login Example"); $client->setClientId($client_id); $client->setClientSecret($client_secret); $client->setRedirectUri($redirect_uri); $client->setDeveloperKey($simple_api_key); $client->addScope(explode(',', $google['scope'])); //Send Client Request $objOAuthService = new \Google_Service_Oauth2($client); //Get User Data from Google Plus //If New, Insert to Database if (!$client->getAccessToken()) { $google['url_join'] = $client->createAuthUrl(); } } return view('home.index')->with(['faq' => $faq, 'stats_show' => $stats_show, 'joinus' => $joinus, 'site' => $site, 'socialntw' => $socialntw, 'daily' => $daily, 'fbook' => $fbook, 'google' => $google]); }
/** * @author: lmkhang - skype * @date: 2016-01-12 * Change password */ public function profile_change_password(Request $request) { //Check Status if ($this->_stop) { return Redirect::intended(url($this->_redirectTo)); } //Post $post = $request->all(); $profile = $post['profile']; //Trim $profile = $this->trim_all($profile); //Setup validation $validator = Validator::make($profile, ['password' => 'required|min:5|max:50', 'confirm_password' => 'required|same:password']); //Checking if ($validator->fails()) { //set Flash Message $this->setFlash('message', 'Errors!'); return redirect()->back(); } //set Title for PAGE $this->_page_title = 'Profile'; //Save profile $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; $this->_admin->password = $this->encryptString($profile['password'], $salt); $this->_admin->save(); //set Flash Message $this->setFlash('message', 'Change password successfully!'); return Redirect::intended(url('/adminntw/profile'))->with('message', 'Change password successfully!'); }
/** * @author: lmkhang - skype * @date: 2016-01-08 * Forgot Password */ public function forgot(Request $request) { //Check isLogged if ($this->isLogged()) { die; } //Post $post = $request->all(); $forgot = $post['forgot']; //Trim $forgot = $this->trim_all($forgot); //Setup validation $validator = Validator::make($forgot, ['email' => 'required|email|min:5|max:100']); // Optionally customize this version using new ->after() /*$validator->after(function() use ($validator) { // Do more validation $validator->errors()->add('field', 'new error'); });*/ //Checking if ($validator->fails()) { // The given data did not pass validation // $session = new \Symfony\Component\HttpFoundation\Session\Session(); // $session->set('messages', $validator->errors()); //set Flash Message $this->setFlash('message', 'Errors!'); return redirect()->back(); } //Check some existed attributes $registration_system = config('constant.registration'); $msg_attributes = $this->checkUserAttributes($forgot, $registration_system['site']); if (!$msg_attributes) { //set Flash Message $this->setFlash('message', 'Errors!'); return redirect()->back(); } //Success $user = new \App\User(); $user = $user->getAccountByEmail($forgot['email']); if ($user) { $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; $pwd = rand(1111111, 999999999); $user->password = $this->encryptString($pwd, $salt); $user->save(); //Send mail $this->_sendmail_forgot($user, $pwd); } //set Flash Message $this->setFlash('message', 'Please check password in email ' . $forgot['email'] . '!'); return Redirect::intended('/')->with('message', 'Please check password in email ' . $forgot['email'] . '!'); }
/** * @author: lmkhang - skype * @date: 2016-01-04 * Checking existed account */ protected function checkAccount($info, $registration_system = 1) { //Check isLogged if ($this->isLogged()) { die; } //Message $result = null; //Check Username if (isset($info['account']) && $info['account'] && isset($info['password']) && $info['password']) { $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; $password = $this->encryptString($info['password'], $salt); $username = \App\User::select('user_id', 'email', 'registration_system')->whereRaw('registration_system = ? AND status = ? AND del_flg = ? AND ( username = ? OR email = ? ) AND password = ? ', [$registration_system, 1, 1, $info['account'], $info['account'], $password])->first(); $result = $username; } return $result; }
public function delete($key) { \App\Config::where('key', $key)->delete(); }
public function getAll($where = []) { $user_in_ex = \App\Config::where($where); $user_in_ex = $user_in_ex->get(); return $user_in_ex; }
/** * @author: lmkhang - skype * @date: 2016-02-03 * Formula for Payment Amount */ public function payment_amount($original_amount, $payment_method) { //get Setting value $currency = \App\Config::where(['prefix' => 'payment', 'name' => 'currency', 'del_flg' => 1])->get()[0]['value']; $tax_pay_bank = \App\Config::where(['prefix' => 'payment', 'name' => 'tax_pay_bank', 'del_flg' => 1])->get()[0]['value']; $amount = $payment_method == 1 ? $original_amount * $currency - $tax_pay_bank : $original_amount; return ['currency' => $payment_method == 1 ? $currency : '', 'tax_pay_bank' => $payment_method == 1 ? $tax_pay_bank : '', 'original_amount' => $original_amount, 'amount' => $amount, 'currency_string' => '$', 'payment_method' => $payment_method, 'string_original_amount' => $original_amount . '$', 'string_amount' => $payment_method == 1 ? number_format($amount, 0, ',', '.') . ' VND' : number_format($amount, 2, ',', '.') . ' $', 'net_amount_word_info' => $payment_method == 1 ? convert_number_to_words(str_replace(array(','), array(''), number_format($amount, 0)), 'vn') . ' Việt Nam Đồng' : convert_number_to_words(str_replace(array(','), array(''), number_format($amount, 2)), 'en') . ' PAYPAL dollars']; }
/** * @author: lmkhang - skype * @date: 2016-01-10 * Checking admin login */ public function admin_login(Request $request) { if ($this->isLoggedAdmin()) { die; } $message = 'This account is not available'; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $post = $request->all(); $info = $this->trim_all($post['login']); $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value']; $pwd = $this->encryptString($info['password'], $salt); $admin_get = new \App\Admin(); $admin = $admin_get->checkAccount($info['account'], $pwd); //set Session if ($admin) { $message = ''; } header('Content-Type: application/json'); echo json_encode(['message' => $message]); exit; } }