/**
  * Run product (Ford models) seeds.
  *
  * @return void
  */
 public function run()
 {
     $products = [['product_name' => 'Aerostar'], ['product_name' => 'Aspire'], ['product_name' => 'Bax'], ['product_name' => 'Bronco'], ['product_name' => 'Cmax'], ['product_name' => 'Capri'], ['product_name' => 'Caravan'], ['product_name' => 'Cargo'], ['product_name' => 'ClubWagon'], ['product_name' => 'ConnectTourneo'], ['product_name' => 'Contour'], ['product_name' => 'Cougar'], ['product_name' => 'Courier'], ['product_name' => 'CrownVictoria'], ['product_name' => 'Econoline'], ['product_name' => 'Econovan'], ['product_name' => 'Edge'], ['product_name' => 'Escape'], ['product_name' => 'Escort'], ['product_name' => 'Excursion'], ['product_name' => 'Expedition'], ['product_name' => 'Explorer'], ['product_name' => 'Express'], ['product_name' => 'F150'], ['product_name' => 'F250'], ['product_name' => 'F350'], ['product_name' => 'F450'], ['product_name' => 'F470'], ['product_name' => 'F700'], ['product_name' => 'Fairlane'], ['product_name' => 'Falcon'], ['product_name' => 'Fiesta'], ['product_name' => 'FiveHundrer'], ['product_name' => 'Flex'], ['product_name' => 'Focus'], ['product_name' => 'FocusCMAX'], ['product_name' => 'Freestar'], ['product_name' => 'Freestyle'], ['product_name' => 'Fusion'], ['product_name' => 'Galaxy'], ['product_name' => 'Granada'], ['product_name' => 'GrandCMAX'], ['product_name' => 'GT'], ['product_name' => 'Ka'], ['product_name' => 'Kuga'], ['product_name' => 'LTD'], ['product_name' => 'Maverick'], ['product_name' => 'Mercury'], ['product_name' => 'Mondeo'], ['product_name' => 'Mustang'], ['product_name' => 'Orion'], ['product_name' => 'Probe'], ['product_name' => 'Puma'], ['product_name' => 'Ranger'], ['product_name' => 'SMAX'], ['product_name' => 'Scorpio'], ['product_name' => 'Sierra'], ['product_name' => 'Sportka'], ['product_name' => 'Streetka'], ['product_name' => 'Superduty'], ['product_name' => 'Taunus'], ['product_name' => 'Taurus'], ['product_name' => 'Tempo'], ['product_name' => 'Thunderbird'], ['product_name' => 'Tourneo'], ['product_name' => 'Transit'], ['product_name' => 'TransitConnect'], ['product_name' => 'Windstar']];
     foreach ($products as $product) {
         Product::create($product);
     }
 }
예제 #2
0
 public function action_parse()
 {
     $source_file_content = \Storage::get('coolbaby_11082015.csv');
     $source_file_rows = explode("\n", $source_file_content);
     array_shift($source_file_rows);
     if (empty($source_file_rows)) {
         $this->error('Массив пуст');
         return;
     }
     $this->output->progressStart(count($source_file_rows));
     foreach ($source_file_rows as $row) {
         $row = trim($row);
         if (empty($row)) {
             continue;
         }
         $fields = explode(';', $row);
         $product_model = \App\Models\Product::create(['code' => trim($fields[0]), 'article' => trim($fields[1]), 'name' => trim($fields[2]), 'category_name' => trim($fields[3]), 'brand' => trim($fields[4]), 'price_2' => trim($fields[5]), 'price_1' => trim($fields[6]), 'catalog_id' => 2]);
         $source_url = 'http://' . substr(trim($fields[7]), 0, -4) . '_big.jpg';
         $media_model = new \App\Models\Media();
         $media_model->product_id = $product_model->id;
         $media_model->source_url = $source_url;
         $media_model->save();
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 50) as $index) {
         Product::create(['title' => $faker->sentence, 'description' => $faker->paragraph(4), 'primary_image_path' => 'main_image_' . rand(1, 4) . '.jpeg', 'delivery' => $faker->boolean(50), 'pickup' => $faker->boolean(50), 'free' => $faker->boolean(50), 'price' => $faker->numberBetween(0, 100), 'user_id' => rand(1, 29), 'university_id' => rand(2, 149)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $categories = Categories::where('parent_id', '>=', 0)->get();
     $baseUrl = 'http://7xkn9n.com1.z0.glb.clouddn.com/img/';
     $string = file_get_contents(__DIR__ . "/../data/products.json");
     $products = json_decode($string, true);
     $cate_ids = [];
     foreach ($categories as $category) {
         $cate_ids[] = $category->id;
     }
     foreach ($products as $productData) {
         try {
             $name = $productData['meta']['title'];
             $content = '';
             if (isset($productData['content'])) {
                 $content = str_replace('<h2 class="title">百科词条</h2>', '', $productData['content']);
             }
             $klass = $productData['meta']['class']['text'];
             $category = Categories::where('name', $klass)->get();
             $description = substr($content, 0, 100);
             $cid = $faker->randomElement($cate_ids);
             if ($category->count() == 1) {
                 $cid = $category[0]->id;
             }
             $pieces = preg_split("/\\//i", $productData['meta']['image']);
             $product = Product::create(['name' => $name, 'slug' => $name, 'description' => $description, 'keywords' => $klass, 'cover' => $baseUrl . $pieces[count($pieces) - 1], 'category_id' => $cid, 'user_id' => 1]);
             $detailTopic = Topic::create(['title' => $name, 'slug' => $name, 'product_id' => $product->id, 'user_id' => 1, 'keywords' => $name, 'description' => $description, 'content' => $content, 'is_product_detail_topic' => true]);
             $product->detail_topic_id = $detailTopic->id;
             $product->save();
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
예제 #5
0
 public function run()
 {
     DB::table('products')->delete();
     Product::create(array('id' => '1', 'name' => 'Шина Gislaved Nord Frost 100 185 / 65 R15 92T XL', 'description' => 'Летная шина Urban Speed идеально подходит как для мегаполисов, так и для небольших городов, обладая прекрасными рабочими характеристиками и сцеплением, она станет  надежным спутником  для автомобилей компакт и среднего классов.', 'count' => '159', 'price' => '1000', 'weight' => '0.1', 'width' => '5', 'height' => '2.4', 'length' => '5'));
     Product::create(array('id' => '2', 'name' => 'Шина Pirelli Formula Energy 175 / 65 R14 82T', 'description' => 'Шины Pirelli разрабатываются с целью максимально раскрыть возможности автомобиля и при этом обеспечить отличную управляемость и устойчивость на любом дорожном покрытии. При экстремальных температурах, погодных условиях и при любом стиле вождения качественные шины Pirelli остаются оптимальным выбором среди экспертов и автолюбителей по всему миру. Многолетний опыт разработки новых технологий для производства шин и постоянная кропотливая исследовательская работа инженеров Pirelli позволили компании занять ведущее место в производстве высококлассных шин для мирового рынка. Новое поколение инноваций от Pirelli заключается в разработке материалов и технологий для улучшения технических и экологических свойств и создания новых качественных характеристик шин.', 'count' => '137', 'price' => '2000', 'weight' => '0.1', 'width' => '5', 'height' => '2.4', 'length' => '5'));
     Product::create(array('id' => '3', 'name' => 'Шина Nokian Nordman SX 165 / 70 R13 79T', 'description' => 'Прочная и экономичная летняя шина, которая подходит для семейных автомобилей малого и среднего классов. Она легко вращается, при её использовании расходуется меньше топлива.', 'count' => '68', 'price' => '3000', 'weight' => '0.1', 'width' => '5', 'height' => '2.4', 'length' => '5'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'description' => 'required', 'category_id' => 'required', 'purchase_price' => 'required', 'price' => 'required']);
     Product::create($request->all());
     Session::flash('flash_message', 'Product added!');
     return redirect('backoffice/products');
 }
예제 #7
0
 /**
  * Store a newly created Product in database.
  *
  * @return Response
  */
 public function store(ProductRequest $request)
 {
     /**
      * Take all inputs except image, store image in seperate variable
      *
      * @var Array
      */
     $input = $request->except('image');
     $image = $request->file('image');
     if ($image != null) {
         // Picture name will be same as SKU
         $name = $input['sku'];
         // Extenstion of original picture
         $extension = '.' . $image->getClientOriginalExtension();
         // Set paths for full image and thumbnail
         $imagePath = 'img/' . $name . $extension;
         $thumbnailPath = 'img/thumbs/' . $name . $extension;
         // Save original picture
         \Image::make($image->getRealPath())->save(public_path($imagePath));
         // Save resized thumbnail
         \Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save(public_path($thumbnailPath));
     } else {
         // Set default 'No image avaliable' images
         $imagePath = self::DEFAULT_IMG;
         $thumbnailPath = self::DEFAULT_IMG;
     }
     // Create Product model and save pictures
     $product = Product::create($input);
     $product->image = $imagePath;
     $product->image_thumb = $thumbnailPath;
     $product->save();
     return redirect(route('AdminProductIndex'));
 }
예제 #8
0
파일: Product.php 프로젝트: sebalb/shopapp
 public function store(UserAuth $user)
 {
     $this->validateJson(request()->all(), $rules = ['title' => 'required|title|min:4|max:60', 'subtitle' => 'title|min:4|max:120', 'description' => 'required', 'price' => 'required|numeric', 'stock_initial' => 'integer', 'stock_available' => 'integer', 'starts' => 'required|date_format:d/m/Y', 'ends' => 'required|date_format:d/m/Y', 'is_active' => 'required|boolean']);
     $data = reqOnlyIfExists(array_keys($rules));
     $data['seller_id'] = $user->id;
     $data['starts'] = \DateTime::createFromFormat('d/m/Y', $data['starts']);
     $data['ends'] = \DateTime::createFromFormat('d/m/Y', $data['ends']);
     // price:
     if ($data['price'] < 0) {
         $this->errorValidateJson(['price' => 'price must be positive']);
     }
     // stock:
     if (isset($data['stock_available']) && !isset($data['stock_initial'])) {
         $data['stock_initial'] = $data['stock_available'];
     }
     if (isset($data['stock_initial']) && !isset($data['stock_available'])) {
         $data['stock_available'] = $data['stock_initial'];
     }
     if (isset($data['stock_initial']) && $data['stock_initial'] < 0) {
         $this->errorValidateJson(['stock_initial' => 'quantity must be zero or positive integer']);
     }
     if (isset($data['stock_initial']) && $data['stock_initial'] < $data['stock_available']) {
         $this->errorValidateJson(['stock_initial' => 'stock initial must be greater than stock available']);
     }
     // start / end:
     if ($data['starts'] >= $data['ends']) {
         $this->errorValidateJson(['starts' => 'start date must be before end date']);
     }
     $starts2 = clone $data['starts'];
     if ($starts2->sub(new \DateInterval('PT1H')) < new \DateTime()) {
         $this->errorValidateJson(['starts' => 'start date must start from present']);
     }
     return \App\Models\Product::create($data);
 }
예제 #9
0
 /**
  * Store items in database.
  *
  * @param CreateProduct $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateProduct $request)
 {
     $data = $this->proccesData($request);
     $product = Product::create($data);
     $product->size()->attach($data['size_id']);
     Session::flash('flash_message', 'Product successfully added!');
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('products')->truncate();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Product::create(['name' => 'Product ' . $index, 'subindustry_id' => Subindustry::all()->get($faker->numberBetween(1, 20))->id]);
     }
 }
예제 #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $objs = factory(Product::class, 30)->make();
     Product::truncate();
     foreach ($objs as $var) {
         Product::create($var->toArray());
     }
 }
예제 #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('products')->truncate();
     $products = [['category_id' => 1, 'name' => 'Tex-Mex Nachos', 'slug' => 'tex-mex-nachos', 'description' => 'Platter of Ncho Chips Topped with Sautees Beef, Cheese Saucce and Flavored Dressing.', 'price' => '250', 'picture' => 'http://restoko.aindong.com/uploads/image1.jpeg'], ['category_id' => 1, 'name' => 'Java Chicken Wings', 'slug' => 'java-chicken-wings', 'description' => 'Deep Fried 3 pieces Chicken wings Coated with BBQ Sauce Served with Crudities in Java Aioli', 'price' => '140', 'picture' => 'http://restoko.aindong.com/uploads/image2.jpeg'], ['category_id' => 2, 'name' => 'Javalicious Braised Short ribs BBQ', 'slug' => 'javalicious-braised-short-ribs-bbq', 'description' => 'Slow cooked Braised Short ribs Served with Com and Carrots Mashed Potatoes with Java BBQ Sauce', 'price' => '275', 'picture' => 'http://restoko.aindong.com/uploads/image3.jpeg'], ['category_id' => 2, 'name' => 'Grilled Pork Steak', 'slug' => 'grilled-pork-steak', 'description' => 'Marinated Pork Steak Grilled to Perfection Served with Buttered Vegetables, Rice and Java Gravy', 'price' => '280', 'picture' => 'http://restoko.aindong.com/uploads/image4.jpeg'], ['category_id' => 2, 'name' => 'Herb and Nut Crusted fish Fillet', 'slug' => 'product-5', 'description' => 'Crispy Pan- Fried Fish fillet  Coated with Herbs and Nuts Served with Green Salad and Rice', 'price' => '190', 'picture' => 'http://restoko.aindong.com/uploads/image5.jpeg'], ['category_id' => 3, 'name' => 'Combo 1', 'slug' => 'combo-1', 'description' => 'Breaded prok with MushrooM Gravy, Rice, Coleslaw, Blue Lemonade, Free Soup', 'price' => '79', 'picture' => 'http://restoko.aindong.com/uploads/image6.jpeg'], ['category_id' => 3, 'name' => 'Combo 2', 'slug' => 'combo-2', 'description' => 'Grilled chicken Breast Inasal,Coleslaw, Rice, Blue Lemonade, Free Soup', 'price' => '79', 'picture' => 'http://restoko.aindong.com/uploads/image7.jpeg'], ['category_id' => 3, 'name' => 'Combo 3', 'slug' => 'combo-3', 'description' => 'Stir-Fried Beef and Vegetables Salpicao, Coleslaw, Rice, Blue Lemonade, Free Soup', 'price' => '99', 'picture' => 'http://restoko.aindong.com/uploads/image8.jpeg'], ['category_id' => 4, 'name' => 'Java Caezar Salad', 'slug' => 'product-7', 'description' => 'Our Version of Caesar salad, Lettuce, Bacon, Croutons, Parmesan Cheese Served with Homemade Caezar Dressing', 'price' => '155', 'picture' => 'http://restoko.aindong.com/uploads/image9.jpeg'], ['category_id' => 4, 'name' => 'Java Garden Salad', 'slug' => 'product-7', 'description' => 'Lettuce, Tomato, Turnips, Carrots, Cucumber, Bell Peppers Served with Honey Orange Vinaigratte', 'price' => '115', 'picture' => 'http://restoko.aindong.com/uploads/image10.jpeg'], ['category_id' => 4, 'name' => 'Java Chicken Pizza7', 'slug' => 'product-7', 'description' => 'Marinated Grilled chicken with Creamy White Sauce over Thinly Baked Crust', 'price' => '165', 'picture' => 'http://restoko.aindong.com/uploads/image11.jpeg'], ['category_id' => 12, 'name' => 'B*****b', 'slug' => 'product-7', 'description' => '', 'price' => '100', 'picture' => ''], ['category_id' => 12, 'name' => 'Blow Job Revenge', 'slug' => 'product-7', 'description' => '', 'price' => '100', 'picture' => ''], ['category_id' => 12, 'name' => '4th of July Tooter', 'slug' => 'product-7', 'description' => '', 'price' => '100', 'picture' => ''], ['category_id' => 12, 'name' => 'Organism', 'slug' => 'product-7', 'description' => '', 'price' => '100', 'picture' => ''], ['category_id' => 12, 'name' => 'Flaming Ferrari', 'slug' => 'product-7', 'description' => '', 'price' => '100', 'picture' => '']];
     foreach ($products as $product) {
         \App\Models\Product::create($product);
     }
 }
 public function store(ProductCreateRequest $request)
 {
     $input = $request->except('categories');
     $input = $this->uploadPicture($input);
     $product = Product::create($input);
     $product->categories()->attach($request->categories);
     return redirect('admin/products');
 }
예제 #14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('products')->delete();
     Product::create(array('name' => 'spam', 'price' => 4.65, 'in_stock' => true));
     Product::create(array('name' => 'spam lite', 'price' => 4.95, 'in_stock' => true));
     Product::create(array('name' => 'spam reduced sodium', 'price' => 4.95, 'in_stock' => true));
     Model::reguard();
 }
예제 #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Products $request)
 {
     $all = $request->all();
     $all['user_id'] = Auth::user()->id;
     $all['image'] = $this->upload($all['image']);
     Product::create($all);
     Session::flash('flash_message', 'Product added!');
     return redirect('products-grid');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(AddProduct $request)
 {
     $file = $request->file('image');
     $file->move('uploads/images', $file->getClientOriginalName());
     $productArr = $request->all();
     $productArr['image'] = $file->getClientOriginalName();
     Product::create($productArr);
     return Redirect::route('productList');
 }
예제 #17
0
 public function run()
 {
     Product::create(['name' => 'Coca Cola', 'price' => 1.5, 'visible' => true, 'category_id' => 1]);
     Product::create(['name' => 'Coca Cola Light', 'price' => 1.5, 'visible' => true, 'category_id' => 1]);
     Product::create(['name' => 'Coca Cola Zero', 'price' => 1.5, 'visible' => true, 'category_id' => 1]);
     Product::create(['name' => 'Ice Tea', 'price' => 2, 'visible' => true, 'category_id' => 1]);
     Product::create(['name' => 'Bicky Burger', 'price' => 3.5, 'visible' => true, 'category_id' => 2]);
     Product::create(['name' => 'Pepperoni', 'price' => 7, 'visible' => true, 'category_id' => 3]);
 }
예제 #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\App\Http\Requests\CreateProductRequest $request)
 {
     $product = \App\Models\Product::create($request->all());
     $fileName = \Carbon\Carbon::now()->timestamp . "_product.jpg";
     $request->file('photo')->move('img', $fileName);
     $product->photo = $fileName;
     $product->save();
     return redirect('categories/' . $product->category->id);
 }
예제 #19
0
 public function save(Request $request)
 {
     //    	$product = Product::create($request->all());
     //        return $product;
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         \App\Models\SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
 }
예제 #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(\App\Http\Requests\CreateProductRequest $request)
 {
     $product = \App\Models\Product::create($request->all());
     //move file from temp location to productPhtots
     $fileName = \Carbon\Carbon::now()->timestamp . "_photo.jpg";
     $request->file('photo')->move('productphotos', $fileName);
     $product->photo = $fileName;
     $product->save();
     return redirect('types/' . $product->type->id);
 }
예제 #21
0
 public function save(Request $request)
 {
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
     $products = Product::all();
     return view('pages.products', ['products' => $products]);
 }
 /**
  * Store a newly created Product in storage.
  *
  * @param CreateProductRequest $request
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $input = $request->all();
     $product = Product::create($input);
     $files = $request->input('files');
     if ($files) {
         $this->syncFiles($product, $files);
     }
     Flash::message('Product saved successfully.');
     return redirect(route('admin.products.index'));
 }
예제 #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $user = Auth::user();
     $input = $request->all();
     $file = $input['files'];
     $file_id = $this->addThumbnail($file);
     $input['fileentry_id'] = $file_id;
     $product = Product::create($input);
     $user->products()->save($product, ['owner' => '1']);
     Flash::message('Product saved successfully.');
     return redirect(route('products.show', [$product->id]));
 }
예제 #24
0
 public function run()
 {
     $this->command->info('Running UserTableSeeder');
     Eloquent::unguard();
     $faker = Faker\Factory::create();
     $company = Company::create();
     $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id, 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]);
     $user = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false, 'is_admin' => 1]);
     $client = Client::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => DEFAULT_COUNTRY, 'currency_id' => DEFAULT_CURRENCY]);
     Contact::create(['user_id' => $user->id, 'account_id' => $account->id, 'client_id' => $client->id, 'public_id' => 1, 'email' => env('TEST_EMAIL', TEST_USERNAME), 'is_primary' => true]);
     Product::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'product_key' => 'ITEM', 'notes' => 'Something nice...', 'cost' => 10]);
     Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
 }
예제 #25
0
 public function store(StoreProductRequest $request)
 {
     $input = $request->all();
     unset($input['picture']);
     $destinationPath = public_path('uploads');
     $fileName = uniqid();
     if ($request->file('picture')->isValid()) {
         $request->file('picture')->move($destinationPath, $fileName);
     }
     $input['picture'] = url('uploads') . '/' . $fileName;
     $input['slug'] = str_replace(' ', '_', strtolower($input['name']));
     $product = Product::create($input);
     return $this->createResponse($product);
 }
예제 #26
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $request_all = $request->all();
     var_dump($request_all);
     exit;
     /*$request_all['price_1'] = str_replace(',', '.', $request_all['price_1']);
       $request_all['price_2'] = str_replace(',', '.', $request_all['price_2']);
       $request_all['price_3'] = str_replace(',', '.', $request_all['price_3']);
       $request_all['price_4'] = str_replace(',', '.', $request_all['price_4']);*/
     $product_model = \App\Models\Product::create($request_all);
     if (array_key_exists('is_apply', $request_all)) {
         return view('admin.product.edit_form', ['model_name' => '\\App\\Models\\Product', 'model_id' => $product_model->id]);
     }
     return redirect("/admin/product");
 }
예제 #27
0
    public function test_getSearchedItems()
    {
        /** Test 1 : tests method with all good inputs .. to be mocked later #TODO **/
        // Create 2 products as a setup
        $faker = Faker\Factory::create();
        for($i=0; $i< 2; $i++)
        {
            $input = array(
                'user_id'               => 1,
                'university_id'         => 20,
                'title'                 => $faker->sentence, 
                'description'           => $faker->paragraph(4),
                'primary_image_path'    => 'main_image_'.rand(1,4).'.jpeg',
                'delivery'              => 1,
                'pickup'                => 1,
                'free'                  => 1,
                'price'                 => 0
            );
            print_r($input);
            $product =  Product::create($input);
            ProductKeyword::create([
                    'product_id'   => $product->id,
                    'keyword_id'   => 10
                ]); 
            ProductKeyword::create([
                    'product_id'   => $product->id,
                    'keyword_id'   => 20
                ]); 
            ProductCategory::create([
                'product_id'   => $product->id,
                'category_id'  => 25
            ]);       

        }

        $whereIn['keyword_id'] = array(10, 20);
        $where['category_id'] = 25;
        $where['university_id'] = 20;
        $where['delivery'] = 1;
        $where['pickup'] = 1;
        $where['free'] = 1;
        $where['price'] = 0;
        $sort['products.updated_at'] = 'desc';
        
        $results = Product::getSearchedItems($where, $whereIn, $sort);
    } 
예제 #28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required', 'range_id' => 'required|integer', 'project_id' => 'required|integer']);
     if ($validator->fails()) {
         return response()->json($validator->errors()->all(), 400);
     }
     try {
         $range = Range::findOrFail($request->input('range_id'));
     } catch (Exception $e) {
         return response()->json('La gamme n\'existe pas.', 404);
     }
     try {
         $project = Project::findOrFail($request->input('project_id'));
     } catch (Exception $e) {
         return response()->json('Le projet n\'existe pas.', 404);
     }
     $product = Product::create($request->all());
     return $product;
 }
 public function store(Request $request)
 {
     $product = new Product();
     $rules = $product->getValidatorRules();
     $validator = $this->validate($request, $rules);
     if ($validator) {
         return response()->json($validator, '404');
     }
     $input = $request->all();
     $file = $request->file('image');
     if ($file && $file->isValid()) {
         $filename = time() . '.' . $file->getClientOriginalExtension();
         $file->move(public_path('upload/product'), $filename);
         $input['image'] = $filename;
     }
     $result = $product->create($input);
     $product->prices()->update(['is_active' => 0]);
     $result->prices()->save(new Price(['price' => $input['price'], 'is_active' => 1, 'created_user_id' => Auth::user()->id]));
     return response()->json(['result' => $result]);
 }
예제 #30
0
 public function action_load()
 {
     $source_file_content = \Storage::get('rino-group.csv');
     $source_file_rows = explode("\n", $source_file_content);
     array_shift($source_file_rows);
     if (empty($source_file_rows)) {
         $this->error('Массив пуст');
         return;
     }
     $source_file_rows = array_slice($source_file_rows, 8);
     $this->output->progressStart(count($source_file_rows));
     foreach ($source_file_rows as $row) {
         $row = trim($row);
         if (empty($row)) {
             continue;
         }
         $fields = explode(';', $row);
         $product_model = \App\Models\Product::create(['code' => trim($fields[1]), 'article' => '', 'name' => trim($fields[2]), 'category_name' => '', 'brand' => trim($fields[3]), 'in_packing' => intval($fields[4]), 'price_1' => trim($fields[5]), 'catalog_id' => 3]);
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }