Exemple #1
0
 public function store(Request $request, $user_model, $bank_model, $address_model)
 {
     $user_data = $this->collectMerchantFormData($request, $user_model, $bank_model, $address_model);
     //dd($user_data);
     $user = new Merchant();
     $user_mer_model = $user->create($user_data);
     //  dd($user_mer_model);
     return $user_mer_model;
 }
 /**
  * @param Request $request
  * @param $id
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function aboutUs(Request $request, $id)
 {
     $merchant = Merchant::find($id);
     $profile = Merchant::withProfile($id);
     if (!$merchant) {
         $request->session()->flash('message', 'Cant find these merchant');
         return redirect()->back();
     }
     //dd($merchant->teams);
     return view('shops.oshopaboutus')->with('merchant', $merchant)->with('profile', $profile);
 }
 private function _createTestMerchant()
 {
     $merchant = new Merchant();
     $merchant->setId(1)->setName('Test Merchant')->save();
     return $merchant;
 }
Exemple #4
0
}
$db->exec(file_get_contents($schemaPath));
/*
 * Parse data from CSV and insert into the database.
 */
if (!file_exists($config->testData->filepath)) {
    throw new Exception('Test data file "' . $config->testData->filepath . '" does not exist.');
}
$testCsvData = array_slice(array_map('str_getcsv', file($config->testData->filepath)), 1);
$currencyConverter = new CurrencyConverter();
foreach ($testCsvData as $testCsvDataRow) {
    if (empty($testCsvDataRow[0])) {
        continue;
    }
    $testDataRow = explode(';', $testCsvDataRow[0]);
    if (empty($testDataRow[0]) || empty($testDataRow[1]) || empty($testDataRow[2])) {
        continue;
    }
    preg_match('/(\\p{Sc})([\\d\\.,]+)/u', str_replace('"', '', $testDataRow[2]), $matches);
    $merchant = new Merchant();
    if (!$merchant->findPk($testDataRow[0])) {
        $merchant->setId($testDataRow[0])->setName('Test Name ' . $testDataRow[0])->save();
    }
    $currency = CurrencyConverter::DEFAULT_SYSTEM_CURRENCY;
    if (!isset(CurrencyConverter::$currencySymbolMap[$matches[1]]) || !($amount = $currencyConverter->convert(CurrencyConverter::$currencySymbolMap[$matches[1]], $currency, $matches[2]))) {
        // TODO: Notify about unsupported / unconverted currency.
        $currency = $matches[1];
        $amount = $matches[2];
    }
    (new Transaction())->setDate(str_replace('"', '', $testDataRow[1]))->setAmount($amount)->setCurrency($currency)->setMerchant($merchant)->save();
}
 public function store(productRequest $request)
 {
     /*$validation = Validator::make($request->all(), [
           'name' => 'required',
           'O-Shop' => 'required',
           'short_description' => 'required',
           'product_photo' => 'required',
           'retail_price' => 'required',
           'original_price' => 'required',
           'available' => 'required',
           'owarehouse_moq' => 'required',
           'owarehouse_price' => 'required',
           'product_details' => 'required',
       ]);
       if ($validation->fails()) {
           return redirect('create_new_product')
               ->withErrors($validation)
               ->withInput();
       }
       else {*/
     /*
      * Get product last id from product table
      */
     $product_id = Product::orderBy('id', 'desc')->take(1)->get();
     foreach ($product_id as $PI) {
         $Pid = $PI->id;
     }
     if (!isset($Pid)) {
         $Pid = 0;
     }
     $Pid = $Pid + 1;
     /*
      * Product table section
      */
     $destination = 'public/images/product/' . $Pid . '/';
     $image = $request->file('product_photo');
     $image_name = $image->getClientOriginalName();
     if ($image->move($destination, $image_name)) {
         //if image moved
         $pro_table = new Product();
         $pro_table->name = $request->name;
         $pro_table->brand_id = $request->brand_id;
         $pro_table->category_id = $request->category_id;
         $pro_table->subcat_id = $request->subcat_id;
         $pro_table->photo_1 = $destination . $image_name;
         if (isset($request->free_delivery)) {
             $pro_table->free_delivery = $request->free_delivery;
             $pro_table->del_worldwide = 0;
             $pro_table->del_west_malaysia = 0;
             $pro_table->del_sabah_labuan = 0;
             $pro_table->del_sarawak = 0;
         } else {
             $pro_table->free_delivery = 0;
             $pro_table->del_worldwide = $request->del_worldwid;
             $pro_table->del_west_malaysia = $request->del_west_malaysia;
             $pro_table->del_sabah_labuan = $request->del_sabah_labuan;
             $pro_table->del_sarawak = $request->del_sarawak;
         }
         $pro_table->cov_country_id = $request->cov_country_id;
         $pro_table->cov_state_id = $request->cov_state_id;
         $pro_table->cov_city_id = $request->cov_city_id;
         $pro_table->retail_price = $request->retail_price;
         $pro_table->original_price = $request->original_price;
         $pro_table->available = $request->available;
         $pro_table->owarehouse_moq = $request->owarehouse_moq;
         $pro_table->owarehouse_price = $request->owarehouse_price;
         $pro_table->product_details = $request->product_details;
         $pro_table->type = 'product';
         $pro_table->save();
         /*
          * Unit and price section....Wholesaletable
          */
         for ($i = 0; $i < count($request->wunit); $i++) {
             $wholwsale_table = new wholesale();
             $wholwsale_table->product_id = $Pid;
             $wholwsale_table->unit = $request->wunit[$i];
             $wholwsale_table->price = $request->wprice[$i];
             $wholwsale_table->save();
         }
         /*
          * Dealer section with speacial price....productdealer table
          */
         for ($i = 0; $i < count($request->dealer); $i++) {
             $productdealer_table = new productdealer();
             $productdealer_table->product_id = $Pid;
             $productdealer_table->dealer_id = $request->dealer[$i];
             $productdealer_table->special_unit = $request->sunit[$i];
             $productdealer_table->special_price = $request->sprice[$i];
             $productdealer_table->save();
         }
         /*
          * Product Specification section..specification table
          */
         /*
          * get last spec id
          */
         $spec_id = specification::orderBy('id', 'desc')->take(1)->get();
         foreach ($spec_id as $SI) {
             $Sid = $SI->id;
         }
         if (!isset($Sid)) {
             $Sid = 1;
         }
         for ($i = 1; $i <= 6; $i++) {
             $spec_table = new specification();
             $spec_table->name = $request->product_specification_name;
             $spec_table->description = $request->product_specification_[$i];
             $spec_table->save();
             //save into subcat_level_1 table;
             $subcat = new SubCatLevel1Spec();
             $subcat->subcat_level_1_id = $request->category_id;
             $subcat->spec_id = $Sid;
             $subcat->save();
             $Sid = $Sid + 1;
         }
         /*
          * Seller information section..address table
          */
         $address_table = new Address();
         $address_table->city_id = 0;
         $address_table->line1 = $request->SFA1;
         $address_table->line2 = $request->SFA3;
         $address_table->line3 = $request->SFA3;
         $address_table->save();
         /*
          * get last enter adress id
          */
         $address_id = Address::orderBy('id', 'desc')->take(1)->get();
         foreach ($address_id as $AI) {
             $Aid = $AI->id;
         }
         /*
          * O-shop and shot-description section ....merchant table
          */
         $merchant_table = new Merchant();
         $merchant_table->User_id = 1;
         //here we get user id//Auth()::user()->id;
         $merchant_table->oshop_name = $request->O - Shop;
         $merchant_table->oshop_name = $request->description;
         $merchant_table->oshop_address_id = $Aid;
         $merchant_table->contact_person = $request->seller_name;
         $merchant_table->return_policy = $request->return_policy;
         $merchant_table->save();
         return "Data saved into tables";
     }
     //}
 }
 public function store(Request $request)
 {
     /*$validation = Validator::make($request->all(), [
           'name' => 'required',
           'O-Shop' => 'required',
           'short_description' => 'required',
           'product_photo' => 'required',
           'retail_price' => 'required',
           'original_price' => 'required',
           'available' => 'required',
           'owarehouse_moq' => 'required',
           'owarehouse_price' => 'required',
           'product_details' => 'required',
       ]);
       if ($validation->fails()) {
           return redirect('create_new_product')
               ->withErrors($validation)
               ->withInput();
       }
       else {*/
     /*
      * Get product last id from product table
      */
     $product_id = Product::orderBy('id', 'desc')->take(1)->get();
     foreach ($product_id as $PI) {
         $Pid = $PI->id;
     }
     if (!isset($Pid)) {
         $Pid = 0;
     }
     $Pid = $Pid + 1;
     /*
      * Product table section
      */
     $destination = 'public/images/product/' . $Pid . '/';
     $image = $request->file('product_photo');
     $image_name = $image->getClientOriginalName();
     if ($image->move($destination, $image_name)) {
         //if image moved
         $pro_table = new Product();
         $pro_table->name = $request->name;
         $pro_table->brand_id = $request->brand_id;
         $pro_table->category_id = $request->category_id;
         $pro_table->subcat_id = $request->subcat_id;
         $pro_table->photo_1 = $destination . $image_name;
         $pro_table->retail_price = $request->retail_price;
         $pro_table->original_price = $request->original_price;
         $pro_table->available = $request->Quantity;
         $pro_table->product_details = $request->product_details;
         $pro_table->type = 'voucher';
         $pro_table->save();
         /*
          * address table
          */
         $address_table = new Address();
         $address_table->city_id = 0;
         $address_table->line1 = $request->VL1;
         $address_table->line2 = $request->VL1;
         $address_table->line3 = $request->VL1;
         $address_table->save();
         /*
          * get last enter adress id
          */
         $address_id = Address::orderBy('id', 'desc')->take(1)->get();
         foreach ($address_id as $AI) {
             $Aid = $AI->id;
         }
         /*
          * Voucher section....voucher table
          */
         //for($i=0;$i<count($request->wholeweek);$i++) {if user chose multi checkboxs
         $voucher_table = new voucher();
         $voucher_table->product_id = $Pid;
         $voucher_table->validity = $request->whole;
         $voucher_table->weekly_duration = $request->wholeweek;
         $voucher_table->start_duration = $request->start_duration;
         $voucher_table->end_duration = $request->years . '-' . $request->months . '-' . $request->days;
         $voucher_table->address_id = $Aid;
         $voucher_table->save();
         //}
         /*
          * get last enter voucher id
          */
         $voucher_id = voucher::orderBy('id', 'desc')->take(1)->get();
         foreach ($voucher_id as $VI) {
             $Vid = $VI->id;
         }
         /*
          * Timealot section....timeslot table
          * timeslot may b many
          */
         for ($i = 0; $i < count($request->from); $i++) {
             $timeslot_table = new timeslot();
             $timeslot_table->voucher_id = Vid;
             $timeslot_table->from = $request->from[$i];
             $timeslot_table->to = $request->to[$i];
             $timeslot_table->price = $request->myrprice[$i];
             $timeslot_table->pax_per_table = $request->fixedprice[$i];
             $timeslot_table->save();
         }
         /*
          * Unit and price section....Wholesaletable
          */
         for ($i = 0; $i < count($request->wunit); $i++) {
             $wholwsale_table = new wholesale();
             $wholwsale_table->product_id = $Pid;
             $wholwsale_table->unit = $request->wunit[$i];
             $wholwsale_table->price = $request->wprice[$i];
             $wholwsale_table->save();
         }
         /*
          * Dealer section with speacial price....productdealer table
          */
         for ($i = 0; $i < count($request->dealer); $i++) {
             $productdealer_table = new productdealer();
             $productdealer_table->product_id = $Pid;
             $productdealer_table->dealer_id = $request->dealer[$i];
             $productdealer_table->special_unit = $request->sunit[$i];
             $productdealer_table->special_price = $request->sprice[$i];
             $productdealer_table->save();
         }
         /*
          * Product Specification section..specification table
          */
         /*
          * get last spec id
          */
         $spec_id = specification::orderBy('id', 'desc')->take(1)->get();
         foreach ($spec_id as $SI) {
             $Sid = $SI->id;
         }
         if (!isset($Sid)) {
             $Sid = 1;
         }
         for ($i = 1; $i <= 6; $i++) {
             $spec_table = new specification();
             $spec_table->name = $request->product_specification_name;
             $spec_table->description = $request->product_specification_[$i];
             $spec_table->save();
             //save into subcat_level_1 table;
             $subcat = new SubCatLevel1Spec();
             $subcat->subcat_level_1_id = $request->category_id;
             $subcat->spec_id = $Sid;
             $subcat->save();
             $Sid = $Sid + 1;
         }
         /*
          * Seller information section..address table
          */
         $address_table = new Address();
         $address_table->city_id = 0;
         $address_table->line1 = $request->SFA1;
         $address_table->line2 = $request->SFA3;
         $address_table->line3 = $request->SFA3;
         $address_table->save();
         /*
          * get last enter adress id
          */
         $address_id = Address::orderBy('id', 'desc')->take(1)->get();
         foreach ($address_id as $AI) {
             $Aid = $AI->id;
         }
         /*
          * O-shop and shot-description section ....merchant table
          */
         $merchant_table = new Merchant();
         $merchant_table->user_id = 1;
         //here we get user id//Auth()::user()->id;
         $merchant_table->oshop_name = $request->O - Shop;
         $merchant_table->oshop_name = $request->description;
         $merchant_table->oshop_address_id = $Aid;
         $merchant_table->contact_person = $request->seller_name;
         $merchant_table->return_policy = $request->return_policy;
         $merchant_table->save();
         return "Data saved into tables";
     }
     //}
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     /*
             $brand_name_array = $request->get('brand_name');
             Models used fo registering a merchant
             User, Bank, Buyer, Address, Merchant, Brand, Website and Director
     */
     $user = new User();
     $user_model = $user->store($request);
     //return new user record in db
     $bank = new Bank();
     $bank_model = $bank->store($request);
     if ($request['indication'] == 'buyer') {
         return "no functionality implemented";
         $buyer = new Buyer();
         $buyer_model = $buyer->store($request, $user_model);
     }
     if ($request['indication'] == 'merchant') {
         //TODO: for adding address first create address then add address id to merchant table
         //country_id   => working
         $address = new Address();
         $address_model = $address->store($request);
         // user_id, country_id, address_id, bank_id => working
         $user_as_merchant = new Merchant();
         $user_as_merchant_model = $user_as_merchant->store($request, $user_model, $bank_model, $address_model);
         /*
          * Document table
          */
         $documents = new Document();
         $documents_model = $documents->store($request, $user_as_merchant_model);
         //todo: add brand
         //1)create merchant and get model
         //2)create all brand and get all models
         //3)sync merchant model with brand models in merchantbrand table
         $brand = new Brand();
         $brand_models = $brand->store($request, $user_as_merchant_model, $address_model);
         //now syncing
         $user_as_merchant_model->attachBrands($user_as_merchant_model, $brand_models);
         //http://laravel.com/docs/5.1/eloquent-relationships#inserting-many-to-many-relationships
         //for storing web sites in "merchantwebsite" table
         //first create merchant and get id
         //then create websites and get website model array like director
         //then attach merchant with each website id
         $website = new Website();
         $website_models = $website->store($request);
         //attachment with merchant in "merchantwebsite" table
         $user_as_merchant->attachWebsites($website_models, $user_as_merchant_model);
         $director = new Director();
         $director_model = $director->store($request, $user_as_merchant_model);
         /*save all FKs of directors & merchants to merchantdirectos tables */
         $user_as_merchant_model->attachDirectors($director_model, $user_as_merchant_model);
         \Session::flash(Config::get('messages.key.name'), $this->messageHandler->success('merchantRegistered', null, null, true, true, true));
     }
     return redirect()->back();
 }
 /**
  * Sets a related merchant.
  *
  * @param Merchant $merchant Merchant object.
  *
  * @return Transaction
  */
 public function setMerchant(Merchant $merchant)
 {
     $this->_merchant = $merchant;
     $this->merchantId = $merchant->getId();
     $merchant->addRelation('transactions', $this);
     return $this;
 }