Ejemplo n.º 1
0
 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'));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 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']);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 6
0
 private function seed(User $user)
 {
     $user->shop()->save(factory(Shop::class)->make());
 }
Ejemplo n.º 7
0
 /**
  * @param User|Shop $seller
  */
 private function seed($seller)
 {
     $seller->paymentMethods()->saveMany(factory(PaymentMethod::class, 3)->make());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 public function update(User $user, Conversation $conversation)
 {
     return $user->canManageConversation($conversation);
 }
Ejemplo n.º 10
0
 public function delete(User $user, Post $post)
 {
     return $user->is($post->getAuthor());
 }
Ejemplo n.º 11
0
 public function update(User $user, Notification $notification)
 {
     return $user->ownsNotification($notification);
 }
Ejemplo n.º 12
0
 public function delete(User $user, ShippingPlan $shippingPlan)
 {
     return $user->sells($shippingPlan);
 }
Ejemplo n.º 13
0
 protected function createUserVerification(User $user) : EmailVerification
 {
     return $user->emailVerification()->save(factory(EmailVerification::class)->make(['email' => $user->email]));
 }
Ejemplo n.º 14
0
 public function delete(User $user, Image $image)
 {
     return $user->sells($image->product);
 }
Ejemplo n.º 15
0
 /**
  * @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());
     });
 }
Ejemplo n.º 16
0
 public function delete(User $user, PaymentMethod $paymentMethod)
 {
     return $user->sells($paymentMethod);
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 18
0
 public function review(User $reviewer, User $reviewee, Order $order)
 {
     return $reviewer->isOrderParticipant($order) and $reviewee->isOrderParticipant($order) and $reviewee->canBeReviewed($order);
 }
Ejemplo n.º 19
0
 public function delete(User $user, Sale $sale)
 {
     return $sale->getProduct()->getSeller()->is($user->getShop());
 }
Ejemplo n.º 20
0
 public function delete(User $user, ShippingOption $shippingOption)
 {
     return $user->sells($shippingOption->getShippingPlan());
 }
Ejemplo n.º 21
0
 public function create(User $user, Review $review)
 {
     return $user->can('reply', $review);
 }
Ejemplo n.º 22
0
 public function handle()
 {
     $this->user->addAvatarFromUrl($this->avatarUrl);
 }
Ejemplo n.º 23
0
 public function delete(User $user, Address $address)
 {
     return $user->owns($address);
 }
Ejemplo n.º 24
0
 public function delete(User $user, CartItem $cartItem)
 {
     return $user->is($cartItem->getUser());
 }
Ejemplo n.º 25
0
 public function delete(User $user, WishlistItem $wishlistItem)
 {
     return $user->is($wishlistItem->getUser());
 }
Ejemplo n.º 26
0
 public function cancel(User $user, Order $order)
 {
     return $user->isOrderParticipant($order) and !$order->isLocked() and $order->hasNotShipped();
 }
Ejemplo n.º 27
0
 public function create(User $user, Order $order, Reviewable $reviewable)
 {
     return $user->can('review', [$reviewable, $order]);
 }