本文整理汇总了PHP中Admin::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::save方法的具体用法?PHP Admin::save怎么用?PHP Admin::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* 管理员录入
*
*/
public function actionCreate()
{
parent::_acl();
$model = new Admin('create');
//所有的用户组
$group = XXcache::get('_adminGroup');
// ppr($group,1);
if (XUtils::method() == 'POST' && !empty($_POST['Admin'])) {
$post = reqPost('Admin');
$password = $post['password'];
if (empty($post['username']) || empty($post['password']) || empty($post['password2']) || $post['password'] != $post['password2']) {
XUtils::message('error', '账号密码不能为空,或者两次输入密码不同');
}
$model->attributes = $post;
$model->setAttribute('password', md5($password));
$id = $model->save();
if (!empty($id)) {
parent::_backendLogger(array('catalog' => 'create', 'intro' => '录入管理员:' . $model->username));
$this->redirect(array('index'));
}
}
$this->group_list = parent::_groupList('admin');
$model->create_time = date('Y-m-d');
$model->last_login_time = date('Y-m-d');
$this->render('create', array('model' => $model, 'group' => $group));
}
示例2: actionAdd
public function actionAdd()
{
$model = new Admin;
if(isset($_POST['Admin'])){
$model->attributes = $_POST['Admin'];
$model->password = md5($_POST['Admin']['password']);
// if(!empty($_POST['purview'])){
// $model->purview=implode(';',$_POST['purview']);
// }else{
// $model->purview='';
// }
// $admin->rid=1;
$model->loginip = $_SERVER['REMOTE_ADDR'];
$model->createtime = time();
$model->updatetime = time();
if($model->save()){
$this->redirect(array('list'));
}
}
$this->render('add',array('model'=>$model));
}
示例3: verify
public function verify()
{
$username = Input::get('username');
$password = Input::get('password');
if (Admin::count() == 0) {
$admin = new Admin();
$admin->username = $username;
$admin->name = $username;
$admin->designation = 'Admin';
$admin->image_url = '';
$admin->password = Hash::make($password);
$admin->remember_token = '';
$admin->save();
return Redirect::to('admin/login');
}
$admin = Admin::where('username', $username)->first();
if ($admin && Hash::check($password, $admin->password)) {
Session::put('admin_id', $admin->id);
Session::put('admin_username', $admin->username);
Session::put('admin_name', $admin->name);
Session::put('admin_image_url', $admin->image_url);
Session::put('admin_designation', $admin->designation);
return Redirect::to('admin/dashboard');
} else {
$message = "Invalid Username and Password";
$type = "failed";
return Redirect::to('/admin/login')->with('type', $type)->with('message', $message);
}
}
示例4: actionCreate
public function actionCreate()
{
IsAuth::Admin();
$model = new Admin();
if (isset($_POST['Admin'])) {
$model->attributes = $_POST['Admin'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->admin_id));
}
}
$this->render('create', array('model' => $model));
}
示例5: run
public function run()
{
DB::table('admins')->truncate();
$admin = new Admin();
$admin->username = "admin_1";
$admin->password = "123456";
$admin->save();
$admin = new Admin();
$admin->username = "admin_2";
$admin->password = "123456";
$admin->save();
}
示例6: newuser
function newuser($data)
{
if ($data['nickname'] && $data['email']) {
$newuser = new Admin();
$newuser->nickname = $_POST['nickname'];
$newuser->email = $_POST['email'];
$newuser->fullname = $_POST['fullname'];
$newuser->save();
return true;
} else {
return false;
}
}
示例7: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Admin();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Admin'])) {
$model->attributes = $_POST['Admin'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->idad));
}
}
$this->render('create', array('model' => $model));
}
示例8: actionAdd
public function actionAdd()
{
$model = new Admin;
if(isset($_POST['Admin'])){
$_POST['Admin']['password'] = md5($_POST['Admin']['password']);
$model->attributes = $_POST['Admin'];
$model->loginip = $_SERVER['REMOTE_ADDR'];
$model->createtime = time();
$model->updatetime = time();
$model->save();
}
$this->render('add',array('model'=>$model));
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Admin();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Admin'])) {
$model->attributes = $_POST['Admin'];
if ($model->save()) {
//$this->redirect(array('view','id'=>$model->id));
Yii::app()->user->setFlash('success', '信息提交成功!');
} else {
Yii::app()->user->setFlash('success', '信息提交失败!');
}
}
$this->render('create', array('model' => $model));
}
示例10: actionCreate
/**
* 管理员录入
*
*/
public function actionCreate()
{
parent::_acl('admin_create');
$model = new Admin('create');
if (isset($_POST['Admin'])) {
$model->attributes = $_POST['Admin'];
$id = $model->save();
if ($id) {
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入管理员:' . $model->username));
$this->redirect(array('index'));
}
}
$this->group_list = parent::_groupList('user');
$model->create_time = date('Y-m-d');
$model->last_login_time = date('Y-m-d');
$this->render('admin_create', array('model' => $model));
}
示例11: actionAdd
public function actionAdd()
{
$model = new Admin();
$model->status = 1;
$model->attributes = Yii::app()->request->getParam('Admin');
if (Yii::app()->request->getParam('Admin') && $model->validate()) {
$get = Yii::app()->request->getParam('Admin');
$model->password = md5($get['password']);
if ($model->save()) {
Yii::app()->user->setFlash('success', '添加成功');
$this->redirect(array('user/index'));
} else {
Yii::app()->user->setFlash('error', '修改失败');
}
}
$this->render('add', array('model' => $model));
}
示例12: elseif
$formValid = false;
}
if (isset($_POST["admin_pass"]) && ($_POST["admin_pass"] == "" || strlen($_POST["admin_pass"]) < 8)) {
$errorMessage .= "Password is required and must be 8 alphanumeric characters. </br>";
$formValid = false;
} else {
if (isset($_POST["admin_pass"]) && $_POST["admin_pass"] != "" && $_POST["admin_pass"] != $_POST["admin_pass_confirm"]) {
$errorMessage .= "Password do not match.";
$formValid = false;
} elseif (isset($_POST["admin_pass"])) {
$_POST["admin_pass"] = md5($_POST["admin_pass"]);
}
}
if (isset($_POST["registration"]) && $_POST["admin_pass"] != "" && $formValid) {
$client = new Admin($_POST);
if ($client->save()) {
$_SESSION["formInput"] = array();
$_POST = array();
$successMessage = "Registration Successful! Click <a href='login.php'>Login</a> to proceed.";
header('Location: ' . $_SERVER['PHP_SELF'] . '?message=' . $successMessage);
die;
} else {
$errorMessage = "Please check fields.";
}
}
// $test = new Admin(array("admin_id"=>"","admin_fname"=>"test","admin_lname"=>"testing","admin_contact"=>"12345678","admin_eadd"=>"email2@yahoo.com","admin_pass"=>"password","admin_add"=>"test address"));
?>
<!DOCTYPE html>
<html>
<head>
示例13: updateAdmin
public function updateAdmin()
{
if (Request::ajax() && Input::has('pk')) {
$arrPost = Input::all();
if ($arrPost['name'] == 'active') {
$arrPost['value'] = (int) $arrPost['value'];
}
Admin::where('id', $arrPost['pk'])->update([$arrPost['name'] => $arrPost['value']]);
return Response::json(['status' => 'ok']);
}
$prevURL = Request::header('referer');
if (!Request::isMethod('post')) {
return App::abort(404);
}
if (Input::has('id')) {
$create = false;
try {
$admin = Admin::findorFail((int) Input::get('id'));
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return App::abort(404);
}
$message = 'has been updated successful';
unset($admin->password);
if (Input::has('password')) {
if (Input::has('password') && Input::has('password_confirmation')) {
$password = Input::get('password');
$admin->password = Input::get('password');
$admin->password_confirmation = Input::get('password_confirmation');
}
}
} else {
$create = true;
$admin = new Admin();
$message = 'has been created successful';
$password = Input::get('password');
$admin->password = $password;
$admin->password_confirmation = Input::get('password_confirmation');
}
$admin->email = Input::get('email');
$admin->first_name = Input::get('first_name');
$admin->last_name = Input::get('last_name');
$admin->active = Input::has('active') ? 1 : 0;
$oldRole = 0;
if (isset($admin->role_id) && $admin->role_id) {
$oldRole = $admin->role_id;
}
$admin->role_id = Input::has('role_id') ? Input::get('role_id') : 0;
if (Input::hasFile('image')) {
$oldPath = $admin->image;
$path = VIImage::upload(Input::file('image'), public_path('assets' . DS . 'images' . DS . 'admins'), 110, false);
$path = str_replace(public_path() . DS, '', $path);
$admin->image = str_replace(DS, '/', $path);
if ($oldPath == $admin->image) {
unset($oldPath);
}
}
$pass = $admin->valid();
if ($pass->passes()) {
if (isset($admin->password_confirmation)) {
unset($admin->password_confirmation);
}
if (isset($password)) {
$admin->password = Hash::make($password);
}
$admin->save();
if ($oldRole != $admin->role_id) {
if ($oldRole) {
$admin->roles()->detach($oldRole);
}
if ($admin->role_id) {
$admin->roles()->attach($admin->role_id);
}
}
if (isset($oldPath) && File::exists(public_path($oldPath))) {
File::delete(public_path($oldPath));
}
if (Input::has('continue')) {
if ($create) {
$prevURL = URL . '/admin/admins/edit-admin/' . $admin->id;
}
return Redirect::to($prevURL)->with('flash_success', "<b>{$admin->first_name} {$admin->last_name}</b> {$message}.");
}
return Redirect::to(URL . '/admin/admins')->with('flash_success', "<b>{$admin->first_name} {$admin->last_name}</b> {$message}.");
}
return Redirect::to($prevURL)->with('flash_error', $pass->messages()->all())->withInput();
}
示例14: verify
public function verify()
{
$username = Input::get('username');
$password = Input::get('password');
if (!Admin::count()) {
$user = new Admin();
$user->username = Input::get('username');
$user->password = $user->password = Hash::make(Input::get('password'));
$user->save();
return Redirect::to('/admin/login');
} else {
if (Auth::attempt(array('username' => $username, 'password' => $password))) {
if (Session::has('pre_admin_login_url')) {
$url = Session::get('pre_admin_login_url');
Session::forget('pre_admin_login_url');
return Redirect::to($url);
} else {
$admin = Admin::where('username', 'like', '%' . $username . '%')->first();
Session::put('admin_id', $admin->id);
return Redirect::to('/admin/report')->with('notify', 'installation Notification');
}
} else {
return Redirect::to('/admin/login?error=1');
}
}
}
示例15: function
$db::schema()->dropIfExists('activity');
$db::schema()->dropIfExists('blocked_ips');
$db::schema()->dropIfExists('blocked_user_agents');
$arraynamesexist = [];
}
if (!in_array('admins', $arraynamesexist)) {
$db->schema()->create('admins', function ($table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->timestamps();
});
$admin = new Admin();
$admin->username = 'admin';
$admin->password = md5('admin');
$admin->save();
echo "created admin table <br>" . PHP_EOL;
echo "admin created: username: admin and password: admin <br>" . PHP_EOL;
}
if (!in_array('categories', $arraynamesexist)) {
$db->schema()->create('categories', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
echo "created categories table <br>" . PHP_EOL;
}
if (!in_array('category_user', $arraynamesexist)) {
$db->schema()->create('category_user', function ($table) {
$table->increments('id');
$table->integer('user_id');