public function sendMails($code) { $admins = Admin::find()->where(['inform' => 1])->all(); $mails = array_map(function ($element) { return $element->email; }, $admins); Yii::$app->mailer->compose(['html' => 'html/new-paste', 'text' => 'text/new-paste'], ['paste' => $code])->setTo($mails)->setFrom('no-reply@' . Yii::$app->request->serverName)->setSubject("New paste #" . $code->id)->send(); }
public function admin() { if (!empty(session('adminId'))) { $adminInstance = Admin::find(Session::get('adminId')); return $adminInstance; } else { return false; } }
public function checkLogin($username, $password) { $password = md5($password); $result = Admin::find('username', 'password')->where(['username' => $username, 'password' => $password])->count(); if ($result == 1) { return TRUE; } else { return FALSE; } }
public function loginAdmin() { /** @var Admin $model */ $model = Admin::find()->where(['email' => $this->username])->one(); if (!is_null($model) && $model->password == $this->password) { return $model; } else { $this->addError('password', Yii::t('app', 'Incorrect User or Password')); return null; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Admin::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'file', $this->file]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = Admin::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->setAttributes($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'admin_role_id' => $this->admin_role_id, 'parent_id' => $this->parent_id, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'last_time' => $this->last_time]); $query->andFilterWhere(['like', 'parent_path', $this->parent_path])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'realname', $this->realname])->andFilterWhere(['like', 'last_ip', $this->last_ip]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Admin::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'login_time', $this->login_time]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Admin::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'type' => $this->type, 'last_login_time' => $this->last_login_time, 'group_id' => $this->group_id, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'ip_address', $this->ip_address])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]); return $dataProvider; }
public function updateProfilAdmin(Request $request) { $input = $request->all(); $validator = $this->profile_validator($input); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $admin = Admin::find($input['id']); $admin->Nama_Admin = $input['Nama_Admin']; $admin->Alamat = $input['Alamat']; $admin->Telepon = $input['Telepon']; $admin->save(); return $this->profiladmin(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Admin::find(); $pagination = new Pagination(['defaultPageSize' => 14, 'totalCount' => $query->count()]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => $pagination]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'permission' => $this->permission, 'age' => $this->age]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'sex', $this->sex])->andFilterWhere(['like', 'pmail', $this->pmail])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
private function tryToLoginFromCookie() { $value = Yii::$app->getRequest()->getCookies()->getValue(self::IDENTITY_COOKIE); if ($value === null) { return null; } $data = json_decode($value, true); if (count($data) !== 2 || !isset($data[0], $data[1])) { return null; } list($username, $duration) = $data; $admin = Admin::find()->where(['email' => $username])->one(); if (!is_null($admin)) { Yii::$app->session->set(self::IDENTITY_SESSION, $admin); } return $admin; }
public function actionDologin() { $username = $_POST['username']; $password = $_POST['password']; $rows = Admin::find()->where(['username' => $username])->one(); //print_r($rows);die; if ($rows) { if ($rows->password == md5($password)) { $session = Yii::$app->session; $session['admin_user'] = ['id' => $rows->_id, 'username' => $username, 'email' => $rows->email]; } else { echo "<script>alert('密码错误');location.href='index.php?r=public/login'</script>"; } } else { echo "<script>alert('无此用户');location.href='index.php?r=public/login'</script>"; } //echo $username."<br/>".$password; }
public function destroy($id) { $admin = Admin::find($id); $admin->delete(); return redirect()->route('dashboard.admin.index'); }
/** * Lists all Admin models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Admin::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionAdmins() { $query = Admin::find()->with('createdBy'); $admins = new ActiveDataProvider(['query' => $query]); return $this->render('admins', ['admins' => $admins]); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // if (env('APP_ENV') != 'testing') { $this->authorizer->validateAccessToken($this->httpHeadersOnly); $this->validateScopes(); // } $owner_id = $this->authorizer->getResourceOwnerId(); if ($owner_id) { list($user_type, $id) = explode(':', $owner_id); switch ($user_type) { case 'admin': $request->user = Admin::find($id); break; default: $request->user = User::find($id); break; } } else { $request->user = new Guest(); } return $next($request); }
public function profile() { $admin = Admin::find($this->getId()); return View('admin.profile')->with('admin', $admin); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $now = date('Y-m-d H:i:s'); // Test Oauth session $session_id = DB::table('oauth_sessions')->insertGetId(['client_id' => 'default', 'owner_type' => 'user', 'owner_id' => "user:1", 'created_at' => $now, 'updated_at' => $now]); DB::table('oauth_access_tokens')->insert(['id' => 'SyjKhdQ1JcKs1S6X18VQW2LaTclJYzW4AC1dfkFk', 'session_id' => $session_id, 'expire_time' => time() + 86400 * 30, 'created_at' => $now, 'updated_at' => $now]); $session_id = DB::table('oauth_sessions')->insertGetId(['client_id' => 'default', 'owner_type' => 'user', 'owner_id' => "admin:1", 'created_at' => $now, 'updated_at' => $now]); DB::table('oauth_access_tokens')->insert(['id' => 'L3gkUwlwCQpUFGwbbX9HuAmc9YsMh8Oe42OQRNiY', 'session_id' => $session_id, 'expire_time' => time() + 86400 * 30, 'created_at' => $now, 'updated_at' => $now]); // User DB::table('users')->truncate(); $user = new User(); $users = array(array('email' => '*****@*****.**', 'nickname' => 'garbin', 'name' => 'Garbin Huang', 'password' => '123456', 'avatar' => 'http://tp3.sinaimg.cn/1812747674/180/5606472968/1')); foreach ($users as $user) { $user = new User($user); $user->save(); } // Operator $operator_user = User::find(1); $operator_admin = Admin::find(1); $operator_system = new SystemOperator(); // Category DB::table('categories')->truncate(); $cate_mac = Category::create(array('category_name' => 'Mac', 'parent_id' => 0)); $cate_mac->children()->create(['category_name' => 'Macbook Pro']); $cate_mac->children()->create(['category_name' => 'Macbook Air']); $cate_mac->children()->create(['category_name' => 'iMac']); $cate_mac->children()->create(['category_name' => 'Mac mini']); $cate_mac->children()->create(['category_name' => 'Mac Pro']); $cate_mac = Category::create(array('category_name' => 'iPhone', 'parent_id' => 0)); $cate_iphone6 = $cate_mac->children()->create(['category_name' => 'iPhone 6']); $cate_iphone5s = $cate_mac->children()->create(['category_name' => 'iPhone 5s']); // Product foreach (['products', 'product_2_category', 'product_photos', 'product_stocks'] as $table) { DB::table($table)->truncate(); } $iphone6 = Product::create(array('product_name' => 'iPhone 6', 'status' => 'available', 'product_desc' => 'Bigger than bigger', 'options' => array(['name' => '颜色', 'options' => ['银色', '深空灰', '香槟金']], ['name' => '容量', 'options' => ['16GB', '64GB', '128GB']]), 'specifications' => [['attr_name' => '高度', 'attr_group' => '重量和尺寸', 'attr_value' => '138.1 毫米(5.44 英寸)'], ['attr_name' => '宽度', 'attr_group' => '重量和尺寸', 'attr_value' => '67.0 毫米 (2.64 英寸)'], ['attr_name' => '厚度', 'attr_group' => '重量和尺寸', 'attr_value' => '6.9 毫米 (0.27 英寸)'], ['attr_name' => '重量', 'attr_group' => '重量和尺寸', 'attr_value' => '129 克 (4.55 盎司)']])); $all_photo = new UploadFile(array('file' => (string) Image::make(database_path() . '/seeds/files/iphone6p-all.png')->encode('data-url'), 'file_name' => 'iphone6p-all.png')); $all_photo->save(); $gray_photo = new UploadFile(array('file' => (string) Image::make(database_path() . '/seeds/files/iphone6p-gray.png')->encode('data-url'), 'file_name' => 'iphone6p-gray.png')); $gray_photo->save(); $gold_photo = new UploadFile(array('file' => (string) Image::make(database_path() . '/seeds/files/iphone6p-gold.png')->encode('data-url'), 'file_name' => 'iphone6p-gold.png')); $gold_photo->save(); $gold_photo = new UploadFile(array('file' => (string) Image::make(database_path() . '/seeds/files/iphone6p-silver.png')->encode('data-url'), 'file_name' => 'iphone6p-silver.png')); $gold_photo->save(); $iphone6->photos()->save(new ProductPhoto(['product_id' => $iphone6->id, 'file_id' => $all_photo->id, 'sort_index' => 0])); $iphone6->photos()->save(new ProductPhoto(['product_id' => $iphone6->id, 'file_id' => $gray_photo->id, 'sort_index' => 1])); $iphone6->photos()->save(new ProductPhoto(['product_id' => $iphone6->id, 'file_id' => $gold_photo->id, 'sort_index' => 2])); $gray_iphone616 = $iphone6->stocks()->create(array('sku' => uniqid(), 'option' => ['深空灰', '16GB'], 'stocks' => 100, 'price' => 5288, 'cover_id' => $gray_photo->id)); $gray_iphone664 = $iphone6->stocks()->create(array('sku' => 'iphone664-gray', 'option' => ['深空灰', '64GB'], 'stocks' => 100, 'price' => 6088)); $gray_iphone6128 = $iphone6->stocks()->create(array('sku' => 'iphone6128-gray', 'option' => ['深空灰', '128GB'], 'stocks' => 100, 'price' => 6888)); $silver_iphone616 = $iphone6->stocks()->create(array('sku' => 'iphone616-gray', 'option' => ['银色', '16GB'], 'stocks' => 100, 'price' => 5288)); $gold_iphone616 = $iphone6->stocks()->create(array('sku' => 'iphone616-gold', 'option' => ['香槟金', '16GB'], 'stocks' => 100, 'price' => 5288)); $iphone5s = Product::create(array('product_name' => 'iPhone 5S', 'status' => 'available', 'product_desc' => 'out stock', 'options' => array(['name' => '颜色', 'options' => ['银色', '深空灰', '香槟金']], ['name' => '容量', 'options' => ['16GB', '32GB', '64GB']]))); $iphone6->categories()->attach($cate_iphone6->id); // Bag foreach (['bags', 'orders', 'order_products', 'logistics', 'payments'] as $table) { DB::table($table)->truncate(); } $logistics = Logistics::create(array('logistics_name' => '标准运送', 'status' => 'enabled', 'logistics_desc' => '标准运送,免费送货', 'deliverer_name' => '\\App\\Plugins\\Offical\\Deliverers\\Simple', 'deliverer_settings' => array('effective' => '当日达', 'price' => 8), 'deliverer_cod' => array('北京' => array('北京' => array('朝阳区')), '福建' => array('福州' => array('仓山区'))))); $payment = Payment::create(array('payment_name' => '支付宝', 'status' => 'enabled', 'payment_desc' => '支付宝即时到账支付', 'gateway_name' => '\\App\\Plugins\\Offical\\Payments\\Alipay\\Main', 'gateway_settings' => array('pid' => '111', 'key' => '222'))); $page = Page::create(["title" => "首页轮播", "pathname" => "index", "position" => "index", "settings" => ['widgets' => json_decode('[{"widget":"Offical.Slider","style":{"padding":"0px","margin":"-50px 0px 0px 0px"},"data":["<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>","<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>"]},{"widget":"Offical.ItemsBelowText","className":"avatar","data":{"title":"Our Customers","subtitle":"They says Apple is awesome!","items":["<img src=\\"https://almsaeedstudio.com/themes/AdminLTE/dist/img/user5-128x128.jpg\\" alt=\\"User Image\\" /><a class=\\"users-list-name\\" href=\\"#\\">Alexander Pierce</a><span class=\\"users-list-date\\">Today</span>","<img src=\\"https://almsaeedstudio.com/themes/AdminLTE/dist/img/user7-128x128.jpg\\" alt=\\"User Image\\" /><a class=\\"users-list-name\\" href=\\"#\\">Alexander Pierce</a><span class=\\"users-list-date\\">Today</span>","<img src=\\"https://almsaeedstudio.com/themes/AdminLTE/dist/img/user6-128x128.jpg\\" alt=\\"User Image\\" /><a class=\\"users-list-name\\" href=\\"#\\">Alexander Pierce</a><span class=\\"users-list-date\\">Today</span>"]}}]')]]); $page = Page::create(["title" => "GoPro Hero 4", "pathname" => "hero4", "position" => "nav", "settings" => ['widgets' => json_decode('[{"widget":"Offical.Header","data":{"title":"GoPro Hero4","subtitle":"Be a hero","links":[{"text":"Overview","active":true,"href":"/hero4"},{"text":"Specs","href":"/hero4/specs"},{"text":"Gallery","href":"/hero4/gallery"},{"text":"Buy now","className":"btn btn-primary btn-sm","href":"/hero4/buy"}]}},{"widget":"Offical.Slider","style":{"padding":"0px","margin":"0px"},"data":["<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>","<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>"]},{"widget":"Offical.ImageParkText","style":{"backgroundColor":"whitesmoke"},"data":{"text":{"title":"Professional video quality.","subtitle":"HERO4 Session delivers stunning video quality. Capture high-resolution 1440p30 and 1080p60 video that’s sharp and lifelike. High frame rate 720p100 video enables exceptionally smooth slow-motion playback of your best moments."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw3d8fb012/cam-respresent-four/HERO4_Session_Feature_2_video.jpg"}},{"style":{"backgroundColor":"white"},"widget":"Offical.ImageParkText","data":{"text":{"title":"Smallest, lightest GoPro yet.","subtitle":"50% smaller and 40% lighter than other HERO4 cameras,1 HERO4 Session is the most wearable and mountable GoPro ever. With a sleek, versatile design, it’s at home anywhere—from the surf to the snow, to hanging with friends."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw80d5e42d/cam-respresent-four/HERO4_Session_Feature_1_smallestlightest.jpg"}},{"style":{"backgroundColor":"white"},"widget":"Offical.ImageParkText","data":{"text":{"title":"Easy one-button control.","subtitle":"A single press of the shutter button powers on the camera and begins capturing video or Time Lapse photos automatically. A second press of the shutter button stops recording and powers off the camera. It’s that simple."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw9f2ed908/cam-respresent-four/HERO4_Session_Feature_6_OneButton.jpg"}}]')]]); $page = Page::create(["title" => "Buy now", "pathname" => "hero4/buy", "position" => "hero4", "settings" => ['widgets' => json_decode('[{"widget":"Offical.Header","data":{"title":"GoPro Hero4","subtitle":"Be a hero","links":[{"text":"Overview","active":true,"href":"/hero4"},{"text":"Specs","href":"/hero4/specs"},{"text":"Gallery","href":"/hero4/gallery"},{"text":"Buy now","className":"btn btn-primary btn-sm","href":"/hero4/buy"}]}},{"widget":"Offical.Slider","style":{"padding":"0px","margin":"0px"},"data":["<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>","<div class=\\"slide-item\\" style=\\"background-image:url(http://images.apple.com/v/home/bx/images/music_hero_medium_2x.jpg)\\"><div class=\\"carousel-caption\\"><h3>Apple Music</h3><p>Free, three-month trial now available</p></div></div>"]},{"widget":"Offical.ImageParkText","style":{"backgroundColor":"whitesmoke"},"data":{"text":{"title":"Professional video quality.","subtitle":"HERO4 Session delivers stunning video quality. Capture high-resolution 1440p30 and 1080p60 video that’s sharp and lifelike. High frame rate 720p100 video enables exceptionally smooth slow-motion playback of your best moments."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw3d8fb012/cam-respresent-four/HERO4_Session_Feature_2_video.jpg"}},{"style":{"backgroundColor":"white"},"widget":"Offical.ImageParkText","data":{"text":{"title":"Smallest, lightest GoPro yet.","subtitle":"50% smaller and 40% lighter than other HERO4 cameras,1 HERO4 Session is the most wearable and mountable GoPro ever. With a sleek, versatile design, it’s at home anywhere—from the surf to the snow, to hanging with friends."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw80d5e42d/cam-respresent-four/HERO4_Session_Feature_1_smallestlightest.jpg"}},{"style":{"backgroundColor":"white"},"widget":"Offical.ImageParkText","data":{"text":{"title":"Easy one-button control.","subtitle":"A single press of the shutter button powers on the camera and begins capturing video or Time Lapse photos automatically. A second press of the shutter button stops recording and powers off the camera. It’s that simple."},"img":"http://demandware.edgesuite.net/aasj_prd/on/demandware.static/-/Sites-gopro-products/default/dw9f2ed908/cam-respresent-four/HERO4_Session_Feature_6_OneButton.jpg"}}]')]]); $page = Page::create(["title" => "DJI Phantom 3", "pathname" => "phantom3", "position" => "nav", "settings" => ['widgets' => []]]); $page = Page::create(["title" => "Apple Watch", "pathname" => "watch", "position" => "nav", "settings" => ['widgets' => []]]); $stock = ProductStock::with('product')->where('sku', '=', 'iphone616-gray')->first(); $order = Order::create(['logistics_consignee' => 'Garbin Huang', 'logistics_region' => ['福建', '福州', '仓山区'], 'logistics_address' => '福湾新城春风苑2区6号楼802', 'logistics_zipcode' => '3500001', 'logistics_mobile' => '18610073651', 'logistics_phone' => '', 'logistics_email' => '*****@*****.**', 'logistics_id' => 1, 'logistics_cod' => false, 'logistics_tracking_number' => '', 'payment_id' => 1, 'user_id' => 1]); $order_products = [new OrderProduct(['product_id' => $stock->product->id, 'product_name' => $stock->product->product_name, 'sku' => $stock->sku, 'option' => $stock->option, 'price' => $stock->price, 'quantity' => 1, 'custom_info' => []])]; $order->calc($order_products); $order->save(); $order_product = $order->products()->saveMany($order_products); // Test Order $stock = ProductStock::with('product')->where('sku', '=', 'iphone616-gold')->first(); $order = Order::create(['logistics_consignee' => 'Garbin Huang', 'logistics_region' => ['福建', '福州', '仓山区'], 'logistics_address' => '福湾新城春风苑2区6号楼802', 'logistics_zipcode' => '3500001', 'logistics_mobile' => '18610073651', 'logistics_phone' => '', 'logistics_email' => '*****@*****.**', 'logistics_id' => 1, 'logistics_cod' => true, 'logistics_tracking_number' => '', 'payment_id' => 1, 'user_id' => 1]); $order_products = [new OrderProduct(['product_id' => $stock->product->id, 'product_name' => $stock->product->product_name, 'sku' => $stock->sku, 'option' => $stock->option, 'price' => $stock->price, 'quantity' => 1, 'custom_info' => []])]; $order->calc($order_products); $order->save(); $order_product = $order->products()->saveMany($order_products); $this->command->info('Test Data seeded'); }