コード例 #1
0
ファイル: AttributeController.php プロジェクト: cdandy/artup
 /**
  * 新商品
  */
 public function save()
 {
     $data = new Attribute();
     $data->cat_id = Input::get('cat_id');
     $data->attr_name = Input::get('attr_name');
     $data->attr_values = Input::get('attr_values');
     $data->attr_input_type = Input::get('attr_input_type');
     $data->attr_type = 0;
     $data->save();
     return redirect()->route('admin.attribute.index');
 }
コード例 #2
0
 public function edit($id)
 {
     $category = Category::find($id);
     $types = Type::with("attributes")->get();
     $categories = $this->get_categories();
     $category->filter_attr = Attribute::with('type.attributes')->whereIn('id', unserialize($category->filter_attr))->get();
     return view('admin.category.edit', ['category' => $category, 'categories' => $categories, 'types' => $types]);
 }
コード例 #3
0
ファイル: AttributeController.php プロジェクト: Jokeramc/amc
 /**
  * do edit data
  * @param mixed $request
  * @param int $id
  * @return redirect
  */
 public function update(Request $request, $id)
 {
     $messages = ['attr_name.required' => 'Attr_name is necessary!'];
     $this->validate($request, ['attr_name' => 'required', 'type_id' => 'integer|not in: 0'], $messages);
     $attribute = Attribute::findOrFail($id);
     $attribute->update($request->all());
     return redirect(route('admin.attribute.index', ['type_id' => $request->input('type_id')]))->with('info', 'Updated Successfully~~');
 }
コード例 #4
0
 public function search(Request $request, $type_id)
 {
     $types = Type::all();
     $keyword = "%" . $request->keyword . "%";
     //        return $keyword;
     $attributes = Attribute::with('type')->where('name', 'like', $keyword)->paginate(config('wyshop.page_size'));
     //        return $attributes;
     return view('admin.attribute.index', ['types' => $types, 'type_id' => $type_id, 'attributes' => $attributes]);
 }
コード例 #5
0
ファイル: DesignController.php プロジェクト: sushilcs111/td
 public function index($slug)
 {
     $category = Category::findBySlug($slug);
     $sizes = array_flatten(Attribute::where("attr", "Shoe Size")->first()->attributeoptions()->select('option_name')->get()->toArray());
     $parts = scandir(public_path() . "/Frontend/shoes/" . $category->folder);
     $parts = array_diff($parts, array('.', '..'));
     $savedList = User::find(Session::get('user')->id)->savedlist;
     //print_r($savedList);
     return view(Config('constants.frontView') . '.design', compact('category', 'parts', 'sizes', 'savedList'));
 }
コード例 #6
0
 public function delete()
 {
     $attr = Attribute::find(Input::get('id'));
     $productAttrs = DB::table('has_options')->where("attr_id", Input::get("id"))->get();
     //dd($productAttrs);
     if (empty($productAttrs)) {
         Attribute::find(Input::get('id'))->attributesets()->detach();
         Attribute::find(Input::get('id'))->attributeoptions()->delete();
         $attr->delete();
         return redirect()->back()->with("message", "Attribute deleted successfully!");
     } else {
         return redirect()->back()->with("message", "This attribute part of product!");
     }
 }
コード例 #7
0
  public function run () 
  {
  
    DB::table('good_attribs')->delete();

    $goods = Good::all();

    $attribs = Attribute::all();

    foreach ($goods as $good) {
    
      foreach ($attribs as $attrib) {

        if ($attrib->code == 'price') {

          GoodAttribute::create([
          
            'gid' => $good->id,

            'aid' => $attrib->id,

            'value' => 398,

            'active' => 1
          
          ]);

        } else {
        
          GoodAttribute::create([
          
            'gid' => $good->id,

            'aid' => $attrib->id,

            'value' => '',

            'active' => 1
          
          ]);
        
        }

      }
    
    }
  
  }
コード例 #8
0
 public function save()
 {
     $attr = Attribute::findOrNew(Input::get('id'));
     $attr->attr = Input::get('attr');
     $attr->attr_type = Input::get('attr_type');
     $attr->is_filterable = Input::get('is_filterable');
     $attr->save();
     $attr->attributesets()->sync(Input::get('attr_set'));
     foreach (Input::get('option_name') as $key => $val) {
         $attrval = AttributeValue::findOrNew(Input::get('idd')[$key]);
         $attrval->option_name = Input::get('option_name')[$key];
         $attrval->option_value = Input::get('option_value')[$key];
         $attrval->is_active = Input::get('is_active')[$key];
         $attrval->sort_order = Input::get('sort_order')[$key];
         $attrval->attr_id = $attr->id;
         $attrval->save();
     }
     return redirect()->route('admin.attrs.view');
 }
コード例 #9
0
ファイル: TypeController.php プロジェクト: Jokeramc/amc
 /**
  * delete data
  * @return json
  */
 public function delete()
 {
     $id = (int) $_POST['id'];
     DB::beginTransaction();
     $rs1 = Type::destroy($id);
     if (!$rs1) {
         DB::rollback();
     }
     $attr = DB::select('select * from it_attributes where type_id = ?', [$id]);
     if ($attr) {
         $rs2 = Attribute::where('type_id', $id)->delete();
         if (!$rs2) {
             DB::rollback();
         }
     }
     DB::commit();
     if ($rs1) {
         return response()->json(array('status' => 200, 'message' => 'Deleted Successfully'));
     } else {
         return response()->json(array('status' => 400, 'message' => 'Delete Failure'));
     }
 }
コード例 #10
0
  public function getCarinfo()
  {
    $user = Auth::user();

    $attributes = Attribute::where('spec', '=', 'file_upload')

      ->where('active', '=', 1)

      ->get();

    $carSet = Car::where('uid', '=', $user->id)

      ->where('active', '=', 1)

      ->orderBy('last_used', 'desc')

      ->orderBy('created_at', 'desc')

      ->get();

    $cars = array();

    foreach ($carSet as $car) {
    
      array_push($cars, $car);
    
    }

    $data = [

      'car_hand' => 'one',
    
      'good_attribs' => $attributes,

      'cars' => $cars,

      'carActive' => true,

      'profile' => true,

      'wTitle' => '个人中心 - 车辆信息'
    
    ];

    return view('profile/carInfo', $data);

  }
コード例 #11
0
 public function del_all(Request $request, $type_id)
 {
     // return $request->all();
     Attribute::destroy($request->del_all);
 }
コード例 #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $attr = Attribute::find($id);
     $attr->delete();
     return Redirect::to('admin/goods_types');
 }
コード例 #13
0
ファイル: ItemController.php プロジェクト: cdandy/meta-admin
 /**
  * 根据属性数组创建属性的表单
  *
  * @access  public
  * @param   int     $cat_id     分类编号
  * @param   int     $item_id   商品编号
  * @return  string
  */
 public function build_attr_html($cat_id, $item_id = 0)
 {
     $GLOBALS['_LANG']['select_please'] = "请选择";
     $GLOBALS['_LANG']['spec_price'] = "规范价格";
     //$attr = get_attr_list($cat_id, $goods_id);
     //获取属性列表
     $attrObj = new Attribute();
     $attr = $attrObj->getAttrList($cat_id, $item_id);
     //  var_dump($attr);exit;
     $html = '<table width="100%" id="attrTable">';
     $spec = 0;
     foreach ($attr as $key => $val) {
         $html .= "<tr><td >";
         if ($val->attr_type == 1 || $val->attr_type == 2) {
             $html .= $spec != $val->attr_id ? "<a href='javascript:;' onclick='addSpec(this)'>[+]</a>" : "<a href='javascript:;' onclick='removeSpec(this)'>[-]</a>";
             $spec = $val->attr_id;
         }
         $html .= $val->attr_name . "</td><td><input type='hidden' name='attr_id_list[]' value='{$val->attr_id}' />";
         if ($val->attr_input_type == 0) {
             $html .= '<input name="attr_value_list[]" type="text" value="' . htmlspecialchars($val->attr_value) . '" size="40" /> ';
         } elseif ($val->attr_input_type == 2) {
             $html .= '<textarea name="attr_value_list[]" rows="3" cols="40">' . htmlspecialchars($val->attr_value) . '</textarea>';
         } else {
             $html .= '<select name="attr_value_list[]">';
             $html .= '<option value="">' . $GLOBALS['_LANG']['select_please'] . '</option>';
             $attr_values = explode("\n", $val->attr_values);
             foreach ($attr_values as $opt) {
                 $opt = trim(htmlspecialchars($opt));
                 $html .= $val->attr_value != $opt ? '<option value="' . $opt . '">' . $opt . '</option>' : '<option value="' . $opt . '" selected="selected">' . $opt . '</option>';
             }
             $html .= '</select> ';
         }
         $html .= $val->attr_type == 1 || $val->attr_type == 2 ? $GLOBALS['_LANG']['spec_price'] . ' <input type="text" name="attr_price_list[]" value="' . $val->attr_price . '" size="5" maxlength="10" />' : ' <input type="hidden" name="attr_price_list[]" value="0" />';
         $html .= '</td></tr>';
     }
     $html .= '</table>';
     return $html;
 }
コード例 #14
0
  public function run () 
  {

    DB::table('attributes')->delete();

    /*价格*/
    Attribute::create([
    
      'name' => '价格',

      'code' => 'price',

      'intro' => '商品的价格',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    /*主图*/
    Attribute::create([
    
      'name' => '主图',

      'code' => 'main_pic',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    /**/
    Attribute::create([
    
      'name' => '副图1',

      'code' => 'sub_pic',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    Attribute::create([

      'name' => '身份证正面扫描件',

      'spec' => 'file_upload',

      'code' => 'identity_face',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    Attribute::create([

      'name' => '身份证背面扫描件',

      'spec' => 'file_upload',

      'code' => 'identity_back',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);


    Attribute::create([

      'name' => '交强险副本扫描件',

      'spec' => 'file_upload',

      'code' => 'trans_ensurance',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    Attribute::create([

      'name' => '车辆购买发票',

      'spec' => 'file_upload',

      'code' => 'car_check',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);


    Attribute::create([

      'name' => '合格证扫描件',

      'spec' => 'file_upload',

      'code' => 'validate_paper',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

    Attribute::create([

      'name' => '行驶证主副页扫描件',

      'spec' => 'file_upload',

      'code' => 'driving_license',

      'intro' => '',

      'parent' => 0,

      'class' => 0,

      'important' => 0,

      'active' => 1
    
    ]);

  }
コード例 #15
0
ファイル: OrdersController.php プロジェクト: kukujiabo/linpai
  public function getIndex(Request $request) 
  {

    $validate = Validator::make($request->input(), [
    
      'gid' => 'required',

      'num' => 'required|min:1',

      'car_hand' => 'required'
    
    ]);

    $carHand = $request->input('car_hand');

    if ($validate->fails()) {

      $failed = $validate->failed();

      $error = '';

      foreach ($failed as $key => $fail) {
      
        $error .= $this->orderindexerror($key);
      
      }
    
    }

    $attribs = Attribute::all();

    $user = Auth::user();

    $gid = $request->input('gid');

    $num = $request->input('gnum');

    $good = Good::where('id', '=', $gid)->first();

    if ($good->code == 'below-three') {

      return redirect('/goods');

    }

    $bouns = Boun::where('uid', '=', $user->id)
      
      ->where('active', '=', 1)

      ->where('type', '=', 1)
      
      ->get();

    if ($good == null) {

      //todo return

    }

    $carsData = Car::where('uid', '=', $user->id)

      ->where('active', '=', 1)

      ->where('car_hand', '=', $carHand)

      ->orderBy('last_used', 'desc')

      ->get();

    $cars = array();

    $defaultCar = null;

    foreach ($carsData as $car) {

      if ($car->last_used) {
      
        $defaultCar = $car;
      
      }
    
      array_push($cars, $car);
    
    }

    $goodAttribsInfo = $this->getGoodAttributesInfo($gid);

    //$citiesData = City::all();

    //$districtsData = District::all();

    $receiverInfosData = ReceiverInfo::where('uid', '=', $user->id)
        
      ->where('active', '=', 1)

      ->orderBy('last_used', 'desc')

      ->get();

    $price = 0;

    foreach ($goodAttribsInfo as $info) {
    
      if ($info->acode == 'price') {
      
        $price = $info->value;
      
      }
    
    }

    //$cities = array();

    //$districts = array();

    $receiverInfos = array();

    $defaultReceiver = null;

    foreach ($receiverInfosData as $receiverInfo) {
    
      array_push($receiverInfos, $receiverInfo);

      if ($receiverInfo->last_used) {
      
        $defaultReceiver = $receiverInfo;
      
      }
    
    }

    $formCode = md5(time());


    $data = [

      'good' => $good,

      'num' => $num,

      'car_hand' => $carHand,

      'good_attribs' => $attribs,

      'car_hand' => $carHand,

      //'cities' => $cities,

      //'districts' => $districts,

      'receiverInfos' => $receiverInfos,

      'cars' => $cars,

      'single_price' => $price,

      'price' => $price * $num,

      'bouns' => $bouns,

      'formCode' => $formCode,

      'is_upload' => true,

      'defaultCar' => $defaultCar,

      'defaultReceiver' => $defaultReceiver,

      'wTitle' => '订单'

    ];

    return view('orders/orderInfo', $data); 

  }
コード例 #16
0
 public function del_all(Request $request, $type_id)
 {
     if (Attribute::destroy($request->del_all)) {
         return back();
     }
 }
コード例 #17
0
  public function getAddcar (Request $request) 
  {
     
    $attribs = Attribute::all();

    $carHand = $request->input('car_hand') == null ? 'one' : $request->input('car_hand');

    $goodCode = $request->input('good_code') == null ? 'below-three' : $request->input('good_code');

    $data = [

      'good_code' => $goodCode,
      
      'attribs' => $attribs,

      'car_hand' => $carHand,

      'header' => '新增车辆'
      
    ];
  
    return view('/mobile/add_car', $data);
  
  }
コード例 #18
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $attr = Attribute::findOrFail($id);
     //  var_dump($itemType);exit;
     $data = ['id' => $id];
     foreach (array_keys($this->fields) as $field) {
         $data[$field] = old($field, $attr->{$field});
     }
     $itemType = ItemType::all();
     return view('admin.attribute.edit', ['data' => $data, 'itemType' => $itemType]);
 }