本文整理汇总了PHP中Shop::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::save方法的具体用法?PHP Shop::save怎么用?PHP Shop::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showShop
public function showShop()
{
$shop = Shop::where('user_id', Auth::user()->id)->first();
if (!$shop) {
$shop = new Shop();
$shop->user_id = Auth::user()->id;
$shop->save();
}
$items = $shop->shopItems;
$total = 0;
foreach ($items as $item) {
$total += $item->item->price;
}
return view('shop', ['items' => $items, 'total' => $total]);
}
示例2: installOrAuthenticate
/**
* Main Controller Method for Shopify Authorization
*/
public function installOrAuthenticate()
{
if (Input::get('code')) {
// New install
Log::info('New Install: ' . Input::get('shop'));
$sh = App::make('ShopifyAPI', ['API_KEY' => Config::get('shopify.APP_API_KEY'), 'API_SECRET' => Config::get('shopify.APP_API_SECRET'), 'SHOP_DOMAIN' => Input::get('shop')]);
// Get Access Token
try {
$accessToken = $sh->getAccessToken(Input::get('code'));
} catch (Exception $e) {
Log::error($e->getMessage());
die('<pre>Error: ' . $e->getMessage() . '</pre>');
}
$shop = Shop::where('domain', Input::get('shop'))->first();
if (!$shop) {
//Log::info(__LINE__ . ': New Shop');
$shop = new Shop();
}
$shop->setDomain(Input::get('shop'));
$shop->setAccessToken($accessToken);
$shop->save();
$this->updateShopInfo($shop);
/**
* Create the shop's first api key automatically, on install
*/
$apiKey = new ApiKey();
$apiKey->shop_id = $shop->id;
$apiKey->public_key = Hash::make($shop->id . 'REMEDY');
$apiKey->access_level_id = AccessLevel::where('title', 'Free Plus')->first()->id;
$apiKey->save();
/**
* Create webhook for uninstall
*/
$hookData = array('webhook' => array('topic' => 'app/uninstalled', 'address' => 'https://' . $_ENV['HOST'] . '/uninstall-hook', 'format' => 'json'));
try {
$sh->setup(['ACCESS_TOKEN' => $shop->getAccessToken()]);
$sh->call(['URL' => 'webhooks.json', 'METHOD' => 'POST', 'DATA' => $hookData]);
} catch (Exception $e) {
Log::error('Issue creating uninstall webhook - ' . $shop->domain . ' : ' . $e->getMessage());
}
Session::put('shop', $shop->domain);
return Redirect::to('/');
} else {
// Accessing app from apps screen
$shop = Shop::where('domain', Input::get('shop'))->first();
if ($shop) {
Log::info('Shop found after Auth: ' . Input::get('shop'));
$this->updateShopInfo($shop);
Session::put('shop', Input::get('shop'));
return Redirect::to('/');
} else {
Log::warning('Shop redirecting to install: ' . Input::get('shop'));
$sh = App::make('ShopifyAPI', ['API_KEY' => Config::get('shopify.APP_API_KEY'), 'SHOP_DOMAIN' => Input::get('shop')]);
return Redirect::to($sh->installURL(['permissions' => Config::get('shopify.APP_API_SCOPE'), 'redirect' => 'https://' . $_ENV['HOST'] . '/auth']));
}
}
}
示例3: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aShop !== null) {
if ($this->aShop->isModified() || $this->aShop->isNew()) {
$affectedRows += $this->aShop->save($con);
}
$this->setShop($this->aShop);
}
if ($this->aConfig !== null) {
if ($this->aConfig->isModified() || $this->aConfig->isNew()) {
$affectedRows += $this->aConfig->save($con);
}
$this->setConfig($this->aConfig);
}
if ($this->isNew()) {
$this->modifiedColumns[] = ShopVitrinPeer::ID;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = ShopVitrinPeer::doInsert($this, $con);
$affectedRows += 1;
// we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setId($pk);
//[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += ShopVitrinPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例4: register
public function register()
{
$mobile = Input::get('user_phone');
$email = Input::get('user_email');
$password = Input::get('user_psw');
//对密码进行hash加密
$password = Hash::make($password);
$user = new User();
$user->password = $password;
$user->last_login_time = time();
$user->last_login_ip = $this->getIP();
$user->lock = 0;
$user->user_type = 'business';
$user->add_time = time();
if ($user->save()) {
$uid = $user->uid;
echo 'uid' . $uid;
} else {
echo "user base Error";
}
# 建business用户
$Buser = new BUser();
$Buser->uid = $uid;
$Buser->email = $email;
$Buser->mobile = $mobile;
$Buser->email_passed = 0;
$Buser->mobile_passed = 1;
if ($Buser->save()) {
echo "ok";
}
# 建店铺
$shop = new Shop();
$shop->b_uid = $Buser->b_uid;
$shop->addtime = time();
if ($shop->save()) {
$Buser->update(array('shop_id' => $shop->id));
Auth::login($Buser);
echo 'hehe';
}
# 建geohash (shop_id, b_uid, x, y, geohash, update_time)
}
示例5: processThemeInstall
public function processThemeInstall()
{
if (Shop::isFeatureActive() && !Tools::getIsset('checkBoxShopAsso_theme')) {
$this->errors[] = $this->l('You must choose at least one shop.');
$this->display = 'ChooseThemeModule';
return;
}
$theme = new Theme((int) Tools::getValue('id_theme'));
$shops = array(Configuration::get('PS_SHOP_DEFAULT'));
if (Tools::isSubmit('checkBoxShopAsso_theme')) {
$shops = Tools::getValue('checkBoxShopAsso_theme');
}
$xml = false;
if (file_exists(_PS_ROOT_DIR_ . '/config/xml/themes/' . $theme->directory . '.xml')) {
$xml = simplexml_load_file(_PS_ROOT_DIR_ . '/config/xml/themes/' . $theme->directory . '.xml');
} elseif (file_exists(_PS_ROOT_DIR_ . '/config/xml/themes/default.xml')) {
$xml = simplexml_load_file(_PS_ROOT_DIR_ . '/config/xml/themes/default.xml');
}
if ($xml) {
$module_hook = array();
foreach ($xml->modules->hooks->hook as $row) {
$name = strval($row['module']);
$exceptions = isset($row['exceptions']) ? explode(',', strval($row['exceptions'])) : array();
if (Hook::getIdByName(strval($row['hook']))) {
$module_hook[$name]['hook'][] = array('hook' => strval($row['hook']), 'position' => strval($row['position']), 'exceptions' => $exceptions);
}
}
$this->img_error = $this->updateImages($xml);
$this->modules_errors = array();
foreach ($shops as $id_shop) {
foreach ($_POST as $key => $value) {
if (strncmp($key, 'to_install', strlen('to_install')) == 0) {
$module = Module::getInstanceByName($value);
if ($module) {
$is_installed_success = true;
if (!Module::isInstalled($module->name)) {
$is_installed_success = $module->install();
}
if ($is_installed_success) {
if (!Module::isEnabled($module->name)) {
$module->enable();
}
if ((int) $module->id > 0 && isset($module_hook[$module->name])) {
$this->hookModule($module->id, $module_hook[$module->name], $id_shop);
}
} else {
$this->modules_errors[] = array('module_name' => $module->name, 'errors' => $module->getErrors());
}
unset($module_hook[$module->name]);
}
} else {
if (strncmp($key, 'to_enable', strlen('to_enable')) == 0) {
$module = Module::getInstanceByName($value);
if ($module) {
$is_installed_success = true;
if (!Module::isInstalled($module->name)) {
$is_installed_success = $module->install();
}
if ($is_installed_success) {
if (!Module::isEnabled($module->name)) {
$module->enable();
}
if ((int) $module->id > 0 && isset($module_hook[$module->name])) {
$this->hookModule($module->id, $module_hook[$module->name], $id_shop);
}
} else {
$this->modules_errors[] = array('module_name' => $module->name, 'errors' => $module->getErrors());
}
unset($module_hook[$module->name]);
}
} else {
if (strncmp($key, 'to_disable', strlen('to_disable')) == 0) {
$key_exploded = explode('_', $key);
$id_shop_module = (int) substr($key_exploded[2], 4);
if ((int) $id_shop_module > 0 && $id_shop_module != (int) $id_shop) {
continue;
}
$module_obj = Module::getInstanceByName($value);
if (Validate::isLoadedObject($module_obj)) {
if (Module::isEnabled($module_obj->name)) {
$module_obj->disable();
}
unset($module_hook[$module_obj->name]);
}
}
}
}
}
$shop = new Shop((int) $id_shop);
$shop->id_theme = (int) Tools::getValue('id_theme');
$this->context->shop->id_theme = $shop->id_theme;
$this->context->shop->update();
$shop->save();
if (Shop::isFeatureActive()) {
Configuration::updateValue('PS_PRODUCTS_PER_PAGE', (int) $theme->product_per_page, false, null, (int) $id_shop);
} else {
Configuration::updateValue('PS_PRODUCTS_PER_PAGE', (int) $theme->product_per_page);
}
}
$this->doc = array();
//.........这里部分代码省略.........
示例6: addShop
/**
* 添加店铺的功能
*
* 对应API:
* 请求类型:POST
* @return array 执行状态信息
*/
public function addShop()
{
$shop = new Shop();
$shop->b_uid = Input::get('b_uid');
// 这是商业用户的id,不是前端给的,从session里面获取
$shop->name = Input::get('name');
$shop->addtime = time();
$shop->intro = Input::get('intro');
$shop->linkname = Input::get('linkname');
//一般电话需要做格式校验
$shop->linktel = Input::get('linktel');
$shop->tel = Input::get('tel');
$shop->address = Input::get('address');
//比如这个价格,只能是数字那么需要加判断
$shop->least_price = Input::get('least_price');
$shop->dispatch_price = Input::get('dispatch_price');
//这个店铺开启状态值,你觉得会让用户在添加店铺的时候设置么?
$shop->state = Input::get('state');
//图片不是这样获取的,你自己查一下PHP是怎么处理前端上传的图片的
$shop->pic = Input::get('pic');
//这种状态值形式的数据,前端给过来的时候,是不会和我们数据库里的形式一样的,你要知道,前端所有代码都是别人能看的,我们能把我们数据库的存储方式放在前端么?
$shop->ticket = Input::get('ticket');
//同上
$shop->pay_method = Input::get('pay_method');
//微信id,也最好做校验,格式
$shop->weixin = Input::get('weixin');
//这里你要看前端是怎么填写,选择还是输入框
$shop->interval = Input::get('interval');
//这里肯定前端只会传两个时间给你,你需要自己拼接字符串啊
$shop->operation_time = Input::get('operation_time');
//同上
$shop->type = Input::get('type');
$shop->reserve = Input::get('reserve');
$shop->support_activity = Input::get('support_activity');
$shop->begin_time = Input::get('begin_time');
$shop->announcement = Input::get('announcement');
$shop->deliver_start_statement = Input::get('deliver_start_statement');
$shop->additions = Input::get('additions');
$shop->save();
}
示例7: postAdd
/**
* 增加店铺
*
* @return Response
*/
public function postAdd()
{
//提交表达数据
$data = Input::all();
//建立验证规则
$rules = array('shop_name' => 'max:64', 'shop_phone' => 'digits:11', 'shop_longitude' => 'required', 'shop_latitude' => 'required', 'shop_addr' => 'max:255', 'shop_keywords' => 'max:128', 'shop_brief' => 'max:255', 'shop_delivery_time' => 'integer|digits_between:1,11|numeric|min:0', 'shop_distance' => 'digits_between:1,12|numeric|min:0');
if ("true" != Input::get('shop_delivery_free')) {
$rules = array_merge($rules, array('shop_delivery_fee' => 'digits_between:1,16|numeric|min:0'));
}
if ("true" == Input::get('shop_has_min_amount')) {
$rules = array_merge($rules, array('shop_delivery_price' => 'digits_between:1,16|numeric|min:0'));
}
//进行验证
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
$userID = Auth::id();
$shopName = Input::get('shop_name');
$shopIcon = Input::get('shop_icon');
$shopIconName = Input::get('shop_icon_name');
$shopType = Input::get('shop_type');
$shopPhone = Input::get('shop_phone');
$shopProvinceID = Input::get('shop_province');
$shopCityID = Input::get('shop_city');
$shopDistrictID = Input::get('shop_district');
$shopRegionID = Input::get('shop_district');
$shopAddr = Input::get('shop_addr');
$shopLng = Input::get('shop_longitude');
$shopLat = Input::get('shop_latitude');
$shopKeywords = Input::get('shop_keywords');
$shopBrief = Input::get('shop_brief');
$shopOpenBegin = Input::get('shop_open_begin');
$shopOpenEnd = Input::get('shop_open_end');
$shopDeliveryBegin = Input::get('shop_delivery_begin');
$shopDeliveryEnd = Input::get('shop_delivery_end');
$shopDeliveryTime = Input::get('shop_delivery_time');
$shopDistance = Input::get('shop_distance');
$shopDistance = round($shopDistance, PRECISION_2);
$shopDeliveryFee;
if ("true" == Input::get('shop_delivery_free')) {
$shopDeliveryFee = DEFAULT_0;
} else {
$shopDeliveryFee = Input::get('shop_delivery_fee');
$shopDeliveryFee = round($shopDeliveryFee, PRECISION_3);
}
$shopDeliveryPrice;
if ("true" == Input::get('shop_has_min_amount')) {
$shopDeliveryPrice = Input::get('shop_delivery_price');
$shopDeliveryPrice = round($shopDeliveryPrice, PRECISION_3);
} else {
$shopDeliveryPrice = DEFAULT_0;
}
$shop = new Shop();
$shop->wy_shopkeeper = $userID;
$shop->wy_shop_name = $shopName;
$shop->wy_shop_icon = $shopIconName;
$shop->wy_shop_type = $shopType;
$shop->wy_phone = $shopPhone;
$shop->wy_province_id = $shopProvinceID;
$shop->wy_city_id = $shopCityID;
$shop->wy_district_id = $shopDistrictID;
$shop->wy_region_id = $shopRegionID;
$shop->wy_addr = $shopAddr;
$shop->wy_longitude = $shopLng;
$shop->wy_latitude = $shopLat;
$shop->wy_keywords = $shopKeywords;
$shop->wy_brief = $shopBrief;
$shop->wy_open_begin = $shopOpenBegin;
$shop->wy_open_end = $shopOpenEnd;
$shop->wy_delivery_begin = $shopDeliveryBegin;
$shop->wy_delivery_end = $shopDeliveryEnd;
$shop->wy_send_up_time = $shopDeliveryTime;
$shop->wy_distance = $shopDistance;
$shop->wy_express_fee = $shopDeliveryFee;
$shop->wy_send_up_price = $shopDeliveryPrice;
$shop->wy_state = SHOP_STATUS_2;
//默认为营业状态
$shop->wy_audit_state = SHOP_AUDIT_STATUS_1;
//默认为未审核状态
$shop->wy_start_time = Carbon::now();
$result = $shop->save();
if ($result) {
//增加图片管理表
$img = new Img();
$img->wy_user_id = $userID;
$img->wy_shop_id = $shop->getShopID();
$img->wy_img_name = $shopIconName;
$img->wy_img_type = IMG_TYPE_2;
$img->wy_create_at = Carbon::now();
$img->save();
return Redirect::back()->with('success', Lang::get('messages.10001'));
} else {
$context = array("errorCode" => -15010, "userID" => $userID, "data" => $data);
Log::error(Lang::get('errormessages.-15010'), $context);
//.........这里部分代码省略.........
示例8: addShop
/**
* 添加店铺
*
* 请求类型:POST
*/
public function addShop()
{
$user = Auth::user();
$record = array('b_uid' => $user->uid, 'name' => Input::get('shop_name'), 'addtime' => time(), 'address' => Input::get('shop_address'), 'intro' => Input::get('shop_statement'), 'type' => Input::get('shop_type'), 'pic' => Input::file('shop_logo'), 'deliver_price' => Input::get('price_begin'), 'begin_time' => Input::get('deliver_begin'), 'operation_time' => Input::get('shop_time'));
$rules = array('name' => 'required | max:50', 'address' => 'required | max:100', 'intro' => 'required | max:2048', 'pic' => 'required | image| max:2048', 'deliver_price' => 'numeric', 'operation_time' => 'required | max:50', 'begin_time' => 'required | max:5', 'type' => 'required | max:45');
$v = Validator::make($record, $rules);
if ($v->fails()) {
$message = $v->messages();
$error['msg'] = $message->toArray();
$error['status'] = '400';
return $error;
}
var_dump($record);
$shop = new Shop($record);
if ($shop->save()) {
return json_encode(array('status' => '200', 'msg' => 'add finished'));
} else {
return json_encode(array('status' => '400', 'msg' => 'add failed'));
}
}
示例9: edit_shop
public function edit_shop(Shop $shop)
{
$rules = array('shop_name' => 'required');
$validator = Validator::make(Input::all(), $rules);
if (!$validator->fails()) {
$shop->update(Input::only('shop_name'));
$shop->save();
return Redirect::to('admin/shops')->with('success', 'Shop updated successfully!');
} else {
return Redirect::back()->withErrors($validator);
}
}
示例10: Shop
// If the group could not be loaded, start making a new one.
if ($shop == null) {
$shop = new Shop($db);
}
if ($SHOP['name'] == null) {
$ERRORS[] = 'No name specified.';
} elseif (strlen($SHOP['name']) > 30) {
$ERRORS[] = 'There is a maxlength=30 on that field for a reason.';
}
if ($SHOP['image'] == null) {
$ERRORS[] = 'No image specified.';
} elseif (strlen($SHOP['image']) > 200) {
$ERRORS[] = 'There is a maxlength=200 on that field for a reason.';
}
if (sizeof($ERRORS) > 0) {
draw_errors($ERRORS);
} else {
$shop->setShopName($SHOP['name']);
$shop->setShopImage($SHOP['image']);
$shop->setWelcomeText($SHOP['welcome_text']);
$shop->save();
$_SESSION['shop_notice'] = "You have saved <strong>{$shop->getShopName()}</strong>.";
redirect('admin-shops');
}
// end no errors
break;
// end save
}
// end state switch
}
// end no errors