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