Example #1
0
 /**
  * Returns all locations from a merchant. If merchant for the user is null (SU), redirects with error
  *
  * @author EA, EB
  * @param User $user
  * @return Collection
  * @throws RedirectException
  */
 protected function fetchMerchantLocationsFromUser(User $user)
 {
     if ($user->merchant_id == null) {
         throw RedirectException::make('/users')->setError('Super Users do not belong to a Merchant, cannot fetch Locations');
     }
     try {
         return $this->fetchMerchantLocations(Merchant::findOrFail($user->merchant_id));
     } catch (ModelNotFoundException $e) {
         throw RedirectException::make('users/' . $user->id)->setError($e->getMessage());
     }
 }
 /**
  * @author EB
  */
 public function testActivateChainsLocation()
 {
     $installation = Installation::query()->find(1);
     $merchant = \App\Basket\Merchant::findOrFail(1)->activate();
     foreach ($installation->locations() as $l1) {
         $l1->active = 0;
     }
     $installation->activate();
     foreach ($installation->locations() as $l2) {
         $this->assertEquals(1, $l2->active);
         $this->assertNotEquals(0, $l2->active);
     }
 }