public function show(User $user)
 {
     if (!$user->isVerified()) {
         abort(404);
     }
     $products = $this->productRepository->whereSeller($user)->scopes('active')->with('image', 'categories')->paginate(10);
     return view('user::__front.show', compact('user', 'products'));
 }
Beispiel #2
0
 public function owns(User $user, $entity, $name = 'seller')
 {
     if (!($owner = $entity->{$name})) {
         return false;
     }
     if ($user->is($owner)) {
         return true;
     }
     return $shop = $user->getShop() and $shop->is($owner);
 }
 public function test_can_verify_email()
 {
     Notification::fake();
     $this->post(route('front::register.post'), ['name' => 'test-user', 'email' => '*****@*****.**', 'password' => 'password', 'password_confirmation' => 'password', 'terms' => 1, 'g-recaptcha-response' => 1]);
     $user = User::where('email', '*****@*****.**')->first();
     Notification::assertSentTo($user, VerifyEmailNotification::class);
     $emailVerification = EmailVerification::latest()->first();
     $this->visit($emailVerification->link)->seeSuccessMessage(trans('authentication::verification.success'))->dontSeeInDatabase('email_verifications', ['email' => 'testuser@example']);
 }
 public function test_unverified_manual_user_log_in()
 {
     $user = $this->createUser(false);
     $provider = $this->getProviderName();
     $oauthUser = $this->mockDriver($provider, ['name' => $user->name, 'email' => $user->email]);
     $this->action('GET', $this->getAction('handleProviderCallback'), $provider);
     $this->assertRedirectWithNoErrors();
     $this->seeInDatabase('users', ['email' => $oauthUser->getEmail(), 'name' => $oauthUser->getName(), $provider . '_id' => $oauthUser->getId()]);
     $user = User::where('email', $oauthUser->getEmail())->first();
     $this->assertNotNull($user->verified_at);
 }
Beispiel #5
0
 public function review(User $user, Product $product, Order $order)
 {
     return $order->isComplete() and $user->isOrderBuyer($order) and $order->hasProduct($product) and !$order->reviews()->whereMorph('reviewable', $product)->exists();
 }
Beispiel #6
0
 private function seed(User $user)
 {
     $user->shop()->save(factory(Shop::class)->make());
 }
 /**
  * @param User|Shop $seller
  */
 private function seed($seller)
 {
     $seller->paymentMethods()->saveMany(factory(PaymentMethod::class, 3)->make());
 }
Beispiel #8
0
 public function review(User $user, Shop $shop, Order $order)
 {
     return $user->is($order->getUser()) and $shop->is($order->getSeller()) and $shop->canBeReviewed($order);
 }
 public function update(User $user, Conversation $conversation)
 {
     return $user->canManageConversation($conversation);
 }
Beispiel #10
0
 public function delete(User $user, Post $post)
 {
     return $user->is($post->getAuthor());
 }
 public function update(User $user, Notification $notification)
 {
     return $user->ownsNotification($notification);
 }
 public function delete(User $user, ShippingPlan $shippingPlan)
 {
     return $user->sells($shippingPlan);
 }
Beispiel #13
0
 protected function createUserVerification(User $user) : EmailVerification
 {
     return $user->emailVerification()->save(factory(EmailVerification::class)->make(['email' => $user->email]));
 }
Beispiel #14
0
 public function delete(User $user, Image $image)
 {
     return $user->sells($image->product);
 }
 /**
  * @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());
     });
 }
 public function delete(User $user, PaymentMethod $paymentMethod)
 {
     return $user->sells($paymentMethod);
 }
Beispiel #17
0
 /**
  * @param User|Shop $owner
  */
 private function seedShippingPlans($owner)
 {
     // create 3 shipping plans for seller
     $shippingPlans = $owner->shippingPlans()->saveMany(factory(ShippingPlan::class, 3)->make());
     $shippingPlans->each(function (ShippingPlan $shippingPlan) {
         $shippingPlan->shippingOptions()->saveMany(factory(ShippingOption::class, 3)->make());
     });
     // assign a random plan to 80% of products
     $products = $owner->products()->get();
     foreach ($products as $product) {
         if ($this->faker->boolean(80)) {
             /** @var Product $product */
             $product->shippingPlans()->attach($shippingPlans->random()->id);
         }
     }
 }
Beispiel #18
0
 public function review(User $reviewer, User $reviewee, Order $order)
 {
     return $reviewer->isOrderParticipant($order) and $reviewee->isOrderParticipant($order) and $reviewee->canBeReviewed($order);
 }
Beispiel #19
0
 public function delete(User $user, Sale $sale)
 {
     return $sale->getProduct()->getSeller()->is($user->getShop());
 }
 public function delete(User $user, ShippingOption $shippingOption)
 {
     return $user->sells($shippingOption->getShippingPlan());
 }
 public function create(User $user, Review $review)
 {
     return $user->can('reply', $review);
 }
 public function handle()
 {
     $this->user->addAvatarFromUrl($this->avatarUrl);
 }
Beispiel #23
0
 public function delete(User $user, Address $address)
 {
     return $user->owns($address);
 }
Beispiel #24
0
 public function delete(User $user, CartItem $cartItem)
 {
     return $user->is($cartItem->getUser());
 }
 public function delete(User $user, WishlistItem $wishlistItem)
 {
     return $user->is($wishlistItem->getUser());
 }
Beispiel #26
0
 public function cancel(User $user, Order $order)
 {
     return $user->isOrderParticipant($order) and !$order->isLocked() and $order->hasNotShipped();
 }
Beispiel #27
0
 public function create(User $user, Order $order, Reviewable $reviewable)
 {
     return $user->can('review', [$reviewable, $order]);
 }