本文整理汇总了PHP中Store::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Store::save方法的具体用法?PHP Store::save怎么用?PHP Store::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
function testDelete()
{
$name = "Zelds";
$test_store = new Store($name);
$test_store->save();
$name = "Granite";
$test_brand = new Brand($name);
$test_brand->save();
$test_brand->addStore($test_brand);
$test_brand->delete();
$this->assertEquals([], $test_brand->getStores());
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Store();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Store'])) {
$model->attributes = $_POST['Store'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->store_id));
}
}
$this->render('create', array('model' => $model));
}
示例3: actionCreate
public function actionCreate()
{
$model = new Store();
if ($_POST['Store']) {
$accessKey = Yii::app()->params['qiniu']['accessKey'];
$secretKey = Yii::app()->params['qiniu']['secretKey'];
$auth = new Auth($accessKey, $secretKey);
$bucket = 'urtime1';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
//上传logo
if ($_FILES['image']['name'] != null) {
$images = array($_FILES['image']);
$images = $this->setImageInformation($images, $token, $uploadMgr);
if ($images) {
$_POST['Store']['image'] = $images[0];
}
unset($_FILES['image']);
}
//上传营业执照
if ($_FILES['bussiness_license1']['name'] != null || $_FILES['bussiness_license2']['name'] != null) {
$images = array($_FILES['bussiness_license1'], $_FILES['bussiness_license2']);
$images = $this->setImageInformation($images, $token, $uploadMgr);
if ($images) {
// $images_str = implode(',',$images);
$_POST['Store']['bussiness_license'] = json_encode($images);
//$images_str;
}
unset($_FILES['bussiness_license1']);
unset($_FILES['bussiness_license2']);
}
//上传介绍图片
if ($_FILES['upImage']['name'] != null) {
$images = $this->setImageInformation($_FILES, $token, $uploadMgr);
if ($images) {
//$images_str = implode(',',$images);
$_POST['Store']['images_str'] = json_encode($images);
//$images_str;
}
}
$model->attributes = $_POST['Store'];
if ($model->validate() && $model->save()) {
//$this->redirect('site/index');
Yii::app()->user->setFlash('create', '成功', '失败');
// Yii::app()->end();
$this->redirect(array('/store/view'));
}
}
$managers = Managers::model()->loadStaffAllModel();
$this->render('create', ['model' => $model, 'managers' => $managers]);
}
示例4: actionCreate
public function actionCreate()
{
$model = new Store();
if (isset($_POST['Store'])) {
$model->setAttributes($_POST['Store']);
if ($model->save()) {
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->end();
} else {
$this->redirect(array('view', 'id' => $model->store_id));
}
}
}
$this->render('create', array('model' => $model));
}
示例5: store
public function store()
{
$rules = ['name' => 'required', 'address' => 'required', 'postal_code' => 'required', 'email' => 'required|email', 'phone' => 'required'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
$password = Input::get('password');
if (Input::has('store_id')) {
$id = Input::get('store_id');
$store = StoreModel::find($id);
if ($password !== '') {
$store->secure_key = md5($store->salt . $password);
}
} else {
$store = new StoreModel();
if ($password === '') {
$alert['msg'] = 'You have to enter password';
$alert['type'] = 'danger';
return Redirect::route('company.store.create')->with('alert', $alert);
}
$store->salt = str_random(8);
$store->token = str_random(8);
$store->secure_key = md5($store->salt . $password);
$store->company_id = Session::get('company_id');
}
$store->name = Input::get('name');
$store->address = Input::get('address');
$store->postal_code = Input::get('postal_code');
$store->email = Input::get('email');
$store->phone = Input::get('phone');
$store->description = Input::get('description');
$store->save();
if (!Input::has('store_id')) {
$status = new StatusModel();
$status->store_id = $store->id;
$startNo = rand(1, 100);
$status->current_queue_no = $startNo;
$status->last_queue_no = $startNo;
$status->save();
}
$alert['msg'] = 'Store has been saved successfully';
$alert['type'] = 'success';
return Redirect::route('company.store')->with('alert', $alert);
}
}
示例6: testGetStores
function testGetStores()
{
$store_name = "Beacons Closet";
$new_store = new Store($store_name);
$new_store->save();
$store_name2 = "Buffalo Exchange";
$new_store2 = new Store($store_name);
$new_store2->save();
$brand_name = "dr.martens";
$new_brand = new Brand($brand_name);
$new_brand->save();
$new_brand->addStore($new_store);
$new_brand->addStore($new_store2);
var_dump($new_brand);
$result = $new_brand->getStores();
var_dump($result);
$this->assertEquals([$new_store, $new_store2], $result);
}
示例7: actionCreateStore
public function actionCreateStore()
{
$model = new Store();
if (isset($_POST['Store'])) {
// print_r($_POST);
// print_r($model->attributes);
// exit;
$model->attributes = $_POST['Store'];
$model->domain = 'shop' . time() . '.' . F::sg('site', 'shopDomain');
$model->theme = 'default';
if ($model->validate()) {
if ($model->save()) {
$this->redirect('http://' . $model->domain);
}
} else {
print_r($model->errors);
}
}
}
示例8: create
public function create()
{
$img = null;
$tmp_img = Input::file('menu');
$tmp_img ? $img = $tmp_img->move('imgs', str_random(12)) : false;
$s = new Store();
$s->name = Input::get('name');
$s->tel = Input::get('tel');
$s->menu = $img ? $img : null;
$s->mime = $img ? $img->getMimeType() : null;
$s->memo = Input::get('memo');
$result = $s->save();
if (!$result) {
$img ? unlink($img) : false;
$json = array('result' => false, 'error' => $s->errors()->all());
return $json;
}
$s->result = true;
return $s;
}
示例9: Brand
function test_addStore()
{
//Arrange
$brand_name = "Nike";
$test_brand = new Brand($brand_name);
$test_brand->save();
$store_name = "Flying Shoes";
$test_store = new Store($store_name);
$test_store->save();
//Act
$test_brand->addStore($test_store);
//Assert
$this->assertEquals($test_brand->getStores(), [$test_store]);
}
示例10: Store
function test_getStores()
{
//Arrange
$id = null;
$store_name = "Fred Meyers";
$test_store = new Store($id, $store_name);
$test_store->save();
$id2 = null;
$store_name2 = "Safeway";
$test_store2 = new Store($id2, $store_name2);
$test_store2->save();
$id3 = null;
$brand_name = "Nike";
$test_brand = new Brand($id3, $brand_name);
$test_brand->save();
$id4 = null;
$brand_name2 = "Vans";
$test_brand2 = new Brand($id4, $brand_name2);
$test_brand2->save();
//Act
$test_brand->addStore($test_store);
$test_brand->addStore($test_store2);
$test_brand2->addStore($test_store2);
//Assert
$this->assertEquals($test_brand->getStores(), [$test_store, $test_store2]);
}
示例11: testGetStores
function testGetStores()
{
//Arrange
$brand_name = "Super Kicks";
$test_brand = new Brand($brand_name);
$test_brand->save();
$store_name = "Shoes Galore";
$test_store = new Store($store_name);
$test_store->save();
$store_name2 = "Save Our Soles";
$test_store2 = new Store($store_name2);
$test_store2->save();
//Act
$test_brand->addStore($test_store);
$test_brand->addStore($test_store2);
$result = $test_brand->getStores();
//Assert
$this->assertEquals([$test_store, $test_store2], $result);
}
示例12: testGetBrands
function testGetBrands()
{
//Arrange
$name = "Shoe Store 1";
$test_store = new Store($name);
$test_store->save();
$brand_name = "Brand name 1";
$test_brand = new Brand($brand_name);
$test_brand->save();
$brand_name2 = "Brand name 2";
$test_brand2 = new Brand($brand_name2);
$test_brand2->save();
//Act
$test_store->addBrand($test_brand);
$test_store->addBrand($test_brand2);
$result = $test_store->getBrands();
//Assert
$this->assertEquals([$test_brand, $test_brand2], $result);
}
示例13: Store
function test_find()
{
$test_name = "Nordstrom";
$test_id = 1;
$test_store = new Store($test_name, $test_id);
$test_store->save();
$test_name2 = "Bloomingdales";
$test_id2 = 2;
$test_store2 = new Store($test_name2, $test_id2);
$test_store2->save();
$result = Store::find($test_store->getId());
$this->assertEquals($test_store, $result);
}
示例14: Store
function test_getBrands()
{
//Arrange
$name = "House of Shoes and Waffles";
$address = "123 Street";
$phone = "4-44";
$test_store = new Store($name, $address, $phone);
$test_store->save();
$test_brand = new Brand("Nike");
$test_brand->save();
$test_brand2 = new Brand("Adidas");
$test_brand2->save();
//Act
$test_store->addBrand($test_brand);
$test_store->addBrand($test_brand2);
//Assert
$result = $test_store->getBrands();
$this->assertEquals([$test_brand, $test_brand2], $result);
}
示例15: actionImportUnsubcribes
public function actionImportUnsubcribes()
{
$this->pageTitle = ' Import unsubscribes | ' . Yii::app()->name;
$this->breadcrumbs = array('Import unsubscribes');
ini_set('auto_detect_line_endings', true);
if (isset($_POST['import'])) {
if (!strlen($_POST['organisation_id'])) {
Yii::app()->user->setFlash('error', 'Choose an organisation');
} else {
//print_r($_FILES);
//exit();
if (!strlen($_FILES['csv']['name'])) {
Yii::app()->user->setFlash('error', 'Choose a file');
} else {
$dupeCount = 0;
$suppressionCount = 0;
$emailsChecked = array();
$emailDupeCount = 0;
$totalCount = 0;
$noRecordCount = 0;
if (($handle = fopen($_FILES['csv']['tmp_name'], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if (sizeof($data) > 1) {
Yii::app()->user->setFlash('error', 'File should only contain 1 column');
break;
} else {
$totalCount++;
$Store = new Store();
$email = strtolower(trim(mb_convert_encoding($data[0], 'UTF-8')));
if (in_array($email, $emailsChecked)) {
$emailDupeCount++;
continue;
}
//add email to emails checked
$emailsChecked[] = $email;
//print $Store->encryptEmail(trim(mb_convert_encoding($data[0], 'UTF-8')));exit();
// Check for matching email in store table
$StoreRows = Store::model()->with('store2contact')->findAll(array('condition' => 'origin_organisation_id = :org_id AND email = :email', 'params' => array(':email' => $Store->encryptEmail($email), ':org_id' => (int) $_POST['organisation_id'])));
if (sizeof($StoreRows)) {
foreach ($StoreRows as $Store) {
if (is_null($Store->store2contact)) {
continue;
}
// Check for existing based on store2contact id
$Suppression = SuppressionList::model()->find(array('condition' => 'store2contact_id = :store2contact_id', 'params' => array(':store2contact_id' => $Store->store2contact->id)));
if (is_null($Suppression)) {
$Suppression = new SuppressionList();
$Suppression->type = SuppressionList::TYPE_UNSUBSCRIBE;
// always save the store id against this row
$Suppression->store_id = $Store->id;
$Suppression->store2contact_id = $Store->store2contact->id;
//We DO NOT need the warehouse id, we're not supressing from everything.
//$Suppression->warehouse_id = $Store->store2contact->contact_warehouse_id;
$Suppression->date = date('Y-m-d H:i:s');
if ($Suppression->save()) {
$suppressionCount++;
}
$Store->contact_email = 0;
$Store->save(true, array("contact_email"));
} else {
$dupeCount++;
}
}
} else {
$noRecordCount++;
}
}
}
Yii::app()->user->setFlash('success', $suppressionCount . ' suppression rows saved. ' . $dupeCount . ' were already suppressed. Number of duplicate emails was ' . $emailDupeCount . '. Total number of rows processed was ' . $totalCount . '. We could not find a match for ' . $noRecordCount . '.');
$this->refresh();
}
fclose($handle);
}
}
}
$this->render('importUnsubcribes', array());
}