Example #1
0
 protected function seedAttributes(Shop $seller)
 {
     $attributeGroups = $seller->attributeGroups()->saveMany(factory(AttributeGroup::class, 3)->make());
     $attributeGroups->each(function (AttributeGroup $attributeGroup) {
         $attributeGroup->attributeOptions()->saveMany(factory(AttributeOption::class, 3)->make());
     });
     return $attributeGroups;
 }
 /**
  * @param User|Shop $seller
  */
 private function seed($seller)
 {
     $seller->paymentMethods()->saveMany(factory(PaymentMethod::class, 3)->make());
 }
Example #3
0
 public function review(User $user, Shop $shop, Order $order)
 {
     return $user->is($order->getUser()) and $shop->is($order->getSeller()) and $shop->canBeReviewed($order);
 }
Example #4
0
 /**
  * Only seed shops.
  *
  * @param Shop $owner
  */
 private function seedAttributes($owner)
 {
     if (!$owner instanceof Shop) {
         return;
     }
     if ($this->faker->boolean(20)) {
         return;
     }
     $attributeGroups = $owner->attributeGroups()->saveMany(factory(AttributeGroup::class, $this->faker->numberBetween(2, 4))->make());
     $attributeGroups->each(function (AttributeGroup $attributeGroup) {
         $attributeGroup->attributeOptions()->saveMany(factory(AttributeOption::class, $this->faker->numberBetween(2, 4))->make());
     });
     $variantManager = app(\App\Modules\ProductModule\Managers\VariantManager::class);
     /** @var Product[] $products */
     $products = $owner->products()->get();
     foreach ($products as $product) {
         if ($this->faker->boolean(20)) {
             continue;
         }
         $options = $attributeGroups->random(2)->pluck('attributeOptions')->flatten(1);
         $product->attributeOptions()->sync($options->pluck('id')->toArray());
         $variantManager->refreshVariants($product);
     }
 }
Example #5
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Modules\ProductModule\Entities\Product;
Route::get('error/{code}', function ($code) {
    return response('测试', 404);
});
Route::get('debug', function () {
    $seller = \App\Modules\ShopModule\Entities\Shop::first();
    dd($seller->products()->with('sale')->toSql());
    $product = \App\Modules\ProductModule\Entities\Product::inRandomOrder()->first();
    dd($product->toSearchableArray());
    return view('debug', ['thing' => $product->toSearchableArray()]);
    return view('front::auth.emails.password', compact('token', 'user'));
});
Route::get('email', function () {
    Auth::user()->notify(new \App\Modules\AuthenticationModule\Notifications\WelcomeNotification(Auth::user()));
    return 'sent';
});
 /**
  * @param User|Shop $seller
  */
 private function seed($seller)
 {
     $seller->shippingPlans()->saveMany(factory(ShippingPlan::class, 3)->make())->each(function (ShippingPlan $shippingPlan) {
         $shippingPlan->shippingOptions()->saveMany(factory(ShippingOption::class, 3)->make());
     });
 }