public function store() { $rules = ['ip' => 'Required|Unique:ips']; $v = Validator::make(Input::all(), $rules); if ($v->passes()) { $ip = new Ip(); $ip->fill(Input::all()); $ip->save(); return Redirect::action('IpController@index'); } else { return Redirect::action('IpController@index')->withErrors($v->getFallbackMessages()); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Ip(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Ip'])) { $model->attributes = $_POST['Ip']; if ($model->save()) { Yii::app()->user->setFlash("success", "<strong>Success!</strong> Successfully added new ip address. {$model->ip_address}"); $this->redirect('ip/allow'); } } $this->render('create', array('model' => $model)); }
function beforeFilter() { parent::beforeFilter(); // Contador de visitas if (!$this->Session->check('Ip')) { $this->Session->write('Ip', 'echo'); $ip = new Ip(); $ip->create(array('ip' => env('REMOTE_ADDR'), 'navegador' => env('HTTP_USER_AGENT'), 'fecha' => getdate())); $ip->save(); } $this->Company_Nombre = 'Rubén Toca Lucio'; $this->Company_Email = '*****@*****.**'; $this->set('Company_Email', $this->Company_Email); $this->set('Company_Nombre', $this->Company_Nombre); // hay que comprobar que estás registrado como administrador if (isset($this->params['admin'])) { $this->checkAdminSession(); } // si no estás registrado Tipo = invitado if (!$this->Session->check('Tipo')) { $this->Session->write('Tipo', 'invitado'); } }