本文整理汇总了PHP中Shop::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::all方法的具体用法?PHP Shop::all怎么用?PHP Shop::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created item in storage.
*
* @return Response
*/
public function store()
{
if (Input::has('clearForm')) {
return Redirect::route('items.index');
}
if (Input::get('selectedItem')) {
$targetID = Input::get('selectedItem');
$item = Item::find($targetID);
$shops = Shop::all();
$categories = Category::all();
return View::make('items.index', compact('item', 'categories', 'shops'));
}
$validator = Validator::make($data = Input::all(), Item::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
/* Item */
if (Input::has('createItem')) {
$id = DB::table('BTSMAS')->count();
$id++;
$file = $id . '.png';
if (move_uploaded_file($_FILES['upload']['tmp_name'], $file)) {
echo $file;
} else {
echo "error";
}
$data['contents'] = file_get_contents($file);
unlink($file);
Item::create($data);
$message = "登録しました。";
}
if (Input::has('deleteItem')) {
$id = Input::get('idItem');
Item::destroy($id);
$message = "削除しました。";
}
if (Input::has('updateItem')) {
$id = Input::get('idItem');
$item = Item::find($id);
$item->title = Input::get('title');
$item->price = Input::get('price');
$item->genka = Input::get('genka');
$item->Bumon = Input::get('Bumon');
$item->Kosu = Input::get('Kosu');
if (file_exists($_FILES['upload']['tmp_name'])) {
$file = $id . '.png';
move_uploaded_file($_FILES['upload']['tmp_name'], $file);
$item->contents = file_get_contents($file);
unlink($file);
}
$item->save();
$message = "更新しました。";
}
return Redirect::route('items.index')->with('message', $message);
}
示例2: index
public function index()
{
/* Employee selected by clicking radio button */
/* ! Remember to clear Input if this is redirected from delete !*/
$selectedEmployee = new Employee();
if (Input::has('selectedEmployee')) {
$selectedEmployee = Employee::find(Input::get('selectedEmployee'));
}
$selectedCategory = new Category();
if (Input::has('selectedCategory')) {
$selectedCategory = Category::find(Input::get('selectedCategory'));
}
$selectedShop = new Shop();
if (Input::has('selectedShop')) {
$selectedShop = Shop::find(Input::get('selectedShop'));
}
$employees = Employee::all();
$categories = Category::all();
$shops = Shop::all();
$item = new Item();
return View::make('employees.index', compact('employees', 'item', 'categories', 'shops', 'selectedEmployee', 'selectedCategory', 'selectedShop'));
}
示例3: getShop_list
/**
* 获取餐厅列表(目测饿了吗是根据地址来推荐的餐厅)
* 两种情况:推荐餐厅和更多餐厅
*
* 对应API:main/blade/my_store 和 main/blade/more_shop
*
* @param integer $uid 用户id
* @param integer $x 经度
* @param integer $y 维度
* @return array 结果数组
*/
public function getShop_list($uid = 2, $x = 0, $y = 0)
{
$result = array();
$data = array();
# 首先获取所有的活动
$activity = Activity::all()->toArray();
#TODO 然后获取推荐的店铺(至于到底返回多少的数量,这个只能根据经纬度的那个算法了)
$shops = array();
//int $i = 0;
$all_shops = Shop::all();
foreach ($all_shops as $shop) {
$onestore = array();
$onestore['support_activity'] = explode(',', $shop->support_activity);
// 所有支持的活动id
$onestore['isHot'] = $shop->is_hot ? true : false;
// 是否是热门餐厅
$onestore['isOnline'] = $shop->is_online ? true : false;
// 是否营业
$onestore['isSupportPay'] = in_array('1', explode(',', $shop->pay_method));
// 是否支持在线支付
$onestore['shop_id'] = $shop->id;
// 商家id
$onestore['place_id'] = $shop->x;
// -------------------位置经纬度和位置id后期再改数据库
$onestore['shop_url'] = 'shop/' . $shop->id;
// 点击跳转到相应商家
$onestore['shop_logo'] = $shop->pic;
// 商家的logo图片地址
$onestore['deliver_time'] = $shop->interval;
// 送货时间间隔
$onestore['deliver_start'] = $shop->begin_time;
// 送货开始时间
$onestore['shop_name'] = $shop->name;
// 商家名称
$onestore['shop_level'] = $shop->level;
// 五分制
$onestore['shop_announce'] = $shop->announcement;
// 商家公告
$onestore['deliver_start_statement'] = $shop->deliver_start_statement;
// 起送价描述
$onestore['shop_address'] = $shop->address;
// 商家地址
$onestore['is_opening'] = $shop->state;
// 0是正在营业,1是打烊了,2是太忙了
$onestore['close_msg'] = $shop->close_msg;
// 关门信息
$onestore['business_hours'] = $shop->operation_time;
// 营业时间
$onestore['shop_summary'] = $shop->intro;
// 商家简介
$onestore['order_count'] = $shop->sold_num;
// 订单数量
$onestore['is_collected'] = in_array($shop->id, Collectshop::where('uid', $uid)->lists('shop_id'));
// 是否被收藏了
$onestore['additions'] = array();
// 额外的内容
array_push($shops, $onestore);
}
$data['activity'] = $activity;
$data['shops'] = $shops;
$result['data'] = $data;
return $result;
}
示例4: run
public function run()
{
$shop = Shop::all()->first();
if (!$shop) {
return;
}
$shopId = $shop->id;
$seedData = [['shopify_id' => '32932092380', 'title' => 'Test Product 1', 'handle' => 'test-product-1', 'body_html' => '<h1>Test Product</h1>', 'vendor' => 'Shopify', 'product_type' => 'Shirts', 'published_at' => '', 'published_scope' => 'global', 'template_suffix' => '', 'tags' => ['TEST', 'RED', 'FLEECE', 'SALE', 'NEW'], 'options' => [['shopify_id' => '3490394803498', 'name' => 'Size', 'position' => 1, 'values' => ['XS', 'S', 'M', 'L', 'XL']], ['shopify_id' => '34903903498', 'name' => 'Color', 'position' => 2, 'values' => ['Red', 'Green', 'Blue', 'Purple', 'Black']], ['shopify_id' => '34903948038', 'name' => 'Material', 'position' => 3, 'values' => ['Fleece', 'Cotton', 'Leather', 'Silk']]], 'metafields' => [['shopify_id' => '349009222', 'namespace' => 'global', 'key' => 'size_chart', 'value' => 'https://google.com'], ['shopify_id' => '349009234322', 'namespace' => 'global', 'key' => 'youtube_video_url', 'value' => 'https://google.com'], ['shopify_id' => '3434349009222', 'namespace' => 'global', 'key' => 'sale_channel_url', 'value' => 'https://google.com']], 'variants' => [['shopify_id' => '398798731937', 'title' => 'M Black Fleece', 'price' => '200.99', 'compare_at_price' => '599.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'M', 'option2' => 'Black', 'option3' => 'Fleece', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '3987981937', 'title' => 'L Red Leather', 'price' => '2000.99', 'compare_at_price' => '5099.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 2000, 'old_inventory_quantity' => 1980, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'L', 'option2' => 'Red', 'option3' => 'Leather', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '398731937', 'title' => 'XL Purple Silk', 'price' => '400.99', 'compare_at_price' => '699.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'XL', 'option2' => 'Purple', 'option3' => 'Silk', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs']]], ['shopify_id' => '329320090980', 'title' => 'Test Product 2', 'handle' => 'test-product-2', 'body_html' => '<h1>Test Product 2</h1>', 'vendor' => 'Shopify', 'product_type' => 'Shirts', 'published_at' => '', 'published_scope' => 'global', 'template_suffix' => '', 'tags' => ['TEST', 'RED', 'FLEECE', 'SALE', 'NEW'], 'options' => [['shopify_id' => '3490394803498', 'name' => 'Size', 'position' => 1, 'values' => ['XS', 'S', 'M', 'L', 'XL']], ['shopify_id' => '34903903498', 'name' => 'Color', 'position' => 2, 'values' => ['Red', 'Green', 'Blue', 'Purple', 'Black']], ['shopify_id' => '34903948038', 'name' => 'Material', 'position' => 3, 'values' => ['Fleece', 'Cotton', 'Leather', 'Silk']]], 'metafields' => [['shopify_id' => '349009222', 'namespace' => 'global', 'key' => 'size_chart', 'value' => 'https://google.com'], ['shopify_id' => '349009234322', 'namespace' => 'global', 'key' => 'youtube_video_url', 'value' => 'https://google.com'], ['shopify_id' => '3434349009222', 'namespace' => 'global', 'key' => 'sale_channel_url', 'value' => 'https://google.com']], 'variants' => [['shopify_id' => '398798731937', 'title' => 'M Black Fleece', 'price' => '200.99', 'compare_at_price' => '599.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'M', 'option2' => 'Black', 'option3' => 'Fleece', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '3987981937', 'title' => 'L Red Leather', 'price' => '2000.99', 'compare_at_price' => '5099.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 2000, 'old_inventory_quantity' => 1980, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'L', 'option2' => 'Red', 'option3' => 'Leather', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '398731937', 'title' => 'XL Purple Silk', 'price' => '400.99', 'compare_at_price' => '699.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'XL', 'option2' => 'Purple', 'option3' => 'Silk', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs']]], ['shopify_id' => '3293297962380', 'title' => 'Test Product 3', 'handle' => 'test-product-3', 'body_html' => '<h1>Test Product 3</h1>', 'vendor' => 'Shopify', 'product_type' => 'Shirts', 'published_at' => '', 'published_scope' => 'global', 'template_suffix' => '', 'tags' => ['TEST', 'RED', 'FLEECE', 'SALE', 'NEW'], 'options' => [['shopify_id' => '3490394803498', 'name' => 'Size', 'position' => 1, 'values' => ['XS', 'S', 'M', 'L', 'XL']], ['shopify_id' => '34903903498', 'name' => 'Color', 'position' => 2, 'values' => ['Red', 'Green', 'Blue', 'Purple', 'Black']], ['shopify_id' => '34903948038', 'name' => 'Material', 'position' => 3, 'values' => ['Fleece', 'Cotton', 'Leather', 'Silk']]], 'metafields' => [['shopify_id' => '349009222', 'namespace' => 'global', 'key' => 'size_chart', 'value' => 'https://google.com'], ['shopify_id' => '349009234322', 'namespace' => 'global', 'key' => 'youtube_video_url', 'value' => 'https://google.com'], ['shopify_id' => '3434349009222', 'namespace' => 'global', 'key' => 'sale_channel_url', 'value' => 'https://google.com']], 'variants' => [['shopify_id' => '398798731937', 'title' => 'M Black Fleece', 'price' => '200.99', 'compare_at_price' => '599.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'M', 'option2' => 'Black', 'option3' => 'Fleece', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '3987981937', 'title' => 'L Red Leather', 'price' => '2000.99', 'compare_at_price' => '5099.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 2000, 'old_inventory_quantity' => 1980, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'L', 'option2' => 'Red', 'option3' => 'Leather', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs'], ['shopify_id' => '398731937', 'title' => 'XL Purple Silk', 'price' => '400.99', 'compare_at_price' => '699.99', 'sku' => 'SL-34566', 'barcode' => '39083094-309309083-393094831', 'position' => 1, 'grams' => '', 'inventory_policy' => '', 'inventory_management' => 'shopify', 'inventory_quantity' => 200, 'old_inventory_quantity' => 198, 'fulfillment_service' => '', 'requires_shipping' => true, 'taxable' => true, 'option1' => 'XL', 'option2' => 'Purple', 'option3' => 'Silk', 'shopify_image_id' => '', 'weight' => '', 'weight_unit' => 'lbs']]]];
DB::table('s_products')->delete();
foreach ($seedData as $seedProduct) {
// products
$product = new Product();
$product->shop_id = $shopId;
$product->shopify_id = $seedProduct['shopify_id'];
$product->title = $seedProduct['title'];
$product->handle = $seedProduct['handle'];
$product->body_html = $seedProduct['body_html'];
$product->vendor = $seedProduct['vendor'];
$product->product_type = $seedProduct['product_type'];
$product->published_at = $seedProduct['published_at'];
$product->published_scope = $seedProduct['published_scope'];
$product->template_suffix = $seedProduct['template_suffix'];
$product->tags = implode(',', $seedProduct['tags']);
$product->save();
// options
if (count($seedProduct['options'])) {
foreach ($seedProduct['options'] as $seedOption) {
$option = new ProductOption();
$option->product_id = $product->id;
$option->shopify_id = $seedOption['shopify_id'];
$option->shopify_product_id = $product->shopify_id;
$option->name = $seedOption['name'];
$option->position = $seedOption['position'];
$option->values = implode(',', $seedOption['values']);
$option->save();
}
}
// metafields
if (count($seedProduct['metafields'])) {
foreach ($seedProduct['metafields'] as $seedMetafield) {
$metafield = new ProductMetafield();
$metafield->product_id = $product->id;
$metafield->shopify_id = $seedMetafield['shopify_id'];
$metafield->shopify_product_id = $product->shopify_id;
$metafield->namespace = $seedMetafield['namespace'];
$metafield->key = $seedMetafield['key'];
$metafield->value = $seedMetafield['value'];
$metafield->save();
}
}
// variants
if (count($seedProduct['variants'])) {
foreach ($seedProduct['variants'] as $seedVariant) {
$variant = new ProductVariant();
$variant->product_id = $product->id;
$variant->shopify_id = $seedVariant['shopify_id'];
$variant->shopify_product_id = $product->shopify_id;
$variant->title = $seedVariant['title'];
$variant->price = $seedVariant['price'];
$variant->compare_at_price = $seedVariant['compare_at_price'];
$variant->sku = $seedVariant['sku'];
$variant->barcode = $seedVariant['barcode'];
$variant->position = $seedVariant['position'];
$variant->grams = $seedVariant['grams'];
$variant->inventory_policy = $seedVariant['inventory_policy'];
$variant->inventory_management = $seedVariant['inventory_management'];
$variant->inventory_quantity = $seedVariant['inventory_quantity'];
$variant->old_inventory_quantity = $seedVariant['old_inventory_quantity'];
$variant->fulfillment_service = $seedVariant['fulfillment_service'];
$variant->requires_shipping = $seedVariant['requires_shipping'];
$variant->taxable = $seedVariant['taxable'];
$variant->option1 = $seedVariant['option1'];
$variant->option2 = $seedVariant['option2'];
$variant->option3 = $seedVariant['option3'];
$variant->shopify_image_id = $seedVariant['shopify_image_id'];
$variant->weight = $seedVariant['weight'];
$variant->weight_unit = $seedVariant['weight_unit'];
$variant->save();
}
}
}
}
示例5: shops
public function shops()
{
$shops = Shop::all();
return View::make('backoffice.shops')->with('shops', $shops);
}
示例6: index
/**
* Display a listing of shops
*
* @return Response
*/
public function index()
{
$shops = Shop::all();
return View::make('shops.index', compact('shops'));
}