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
          
          ]);
        
        }

      }
    
    }
  
  }
예제 #2
0
  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); 

  }
예제 #3
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);
  
  }
예제 #4
0
 public function index()
 {
     $attr = Attribute::all();
     return view("admin.attribute.index", ['data' => $attr]);
 }