Ejemplo n.º 1
0
 /**
  * @test
  */
 public function canDeleteAddress()
 {
     $address = $this->guardian()->addresses()->orderBy('created_at', 'DESC')->first();
     // Because of the dropdown menu's functionality for delete being
     // in javascript we'll have to simulate the request
     $address->delete();
     // bypassing caching, see above comments
     $this->assertEquals(0, Address::where('id', $address->id)->count());
 }
Ejemplo n.º 2
0
 private function seedKeithHeadCoach()
 {
     $address = Address::create(['name' => 'Home', 'address_one' => '5900 Casa Del Rey Cir', 'address_two' => null, 'latitude' => '28.470933', 'longitude' => '-81.425187', 'city' => 'Orlando', 'state' => 'FL', 'zip_code' => '32809']);
     $headCoach = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => 'Keith', 'last_name' => 'HeadCoach', 'email' => '*****@*****.**', 'password' => bcrypt('biblebowl'), 'primary_address_id' => $address->id]);
     $headCoach->addresses()->save($address);
     /** @var GroupCreator $groupCreator */
     $groupCreator = App::make(GroupCreator::class);
     $groupCreator->create($headCoach, ['name' => 'Florida Homeschoolers', 'group_type_id' => GroupType::HOMESCHOOL, 'program_id' => Program::TEEN, 'address_id' => $address->id, 'meeting_address_id' => $address->id]);
     $address = factory(Address::class)->create(['name' => 'Church', 'latitude' => '39.285121', 'longitude' => '-84.4721087']);
     $headCoach->addresses()->save($address);
     $headCoach = User::findOrFail($headCoach->id);
     $this->seedGroupWithPlayers($groupCreator, $headCoach, $address, 'KSmith Christian Church', '28.472610', '-81.418877');
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $homeAddress = Address::create(['name' => 'Home', 'address_one' => '123 Acceptance Test Seeder Street', 'address_two' => null, 'city' => 'Louisville', 'state' => 'KY', 'zip_code' => '40241']);
     $TestUser = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => self::USER_FIRST_NAME, 'last_name' => self::USER_LAST_NAME, 'email' => self::USER_EMAIL, 'password' => bcrypt(self::USER_PASSWORD), 'primary_address_id' => $homeAddress->id]);
     $TestUser->addresses()->save($homeAddress);
     // used for asserting you can't login without being confirmed
     User::create(['first_name' => self::USER_FIRST_NAME . '-unconfirmed', 'last_name' => self::USER_LAST_NAME, 'email' => self::UNCONFIRMED_USER_EMAIL, 'password' => bcrypt(self::USER_PASSWORD), 'primary_address_id' => $homeAddress->id]);
     $this->seedGuardian();
     $this->seedReceipts();
     if (app()->environment('local')) {
         $this->updateMailchimpIds();
     }
 }
Ejemplo n.º 4
0
 private function seedHeadCoach()
 {
     $address = Address::create(['name' => 'Home', 'address_one' => '11025 Eagles Cove Dr.', 'address_two' => null, 'latitude' => '38.2515659', 'longitude' => '-85.615241', 'city' => 'Louisville', 'state' => 'KY', 'zip_code' => '40241']);
     $BKuhlHeadCoach = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => 'Ben', 'last_name' => 'HeadCoach', 'email' => self::HEAD_COACH_EMAIL, 'password' => bcrypt('changeme'), 'primary_address_id' => $address->id]);
     $BKuhlHeadCoach->addresses()->save($address);
     /** @var GroupCreator $groupCreator */
     $groupCreator = App::make(GroupCreator::class);
     $groupCreator->create($BKuhlHeadCoach, ['name' => 'Southeast Christian Church', 'group_type_id' => GroupType::CHURCH, 'program_id' => Program::TEEN, 'address_id' => $address->id, 'meeting_address_id' => $address->id]);
     $address = factory(Address::class)->create(['name' => 'Church', 'latitude' => '38.316334', 'longitude' => '-85.573143']);
     $BKuhlHeadCoach->addresses()->save($address);
     $BKuhlHeadCoach = User::findOrFail($BKuhlHeadCoach->id);
     $group = $this->seedGroupWithPlayers($groupCreator, $BKuhlHeadCoach, $address);
     $this->seedTeamSet($group);
     return $BKuhlHeadCoach;
 }
 /**
  * Handle the event.
  *
  * @param Address $address
  *
  * @return void
  */
 public function handle(Address $address)
 {
     if (app()->environment('testing')) {
         app('log')->info('Not fetching coordinates for address while testing');
         return;
     }
     try {
         // object was serialized, so get a new one with DB connectivity
         $address = Address::findOrFail($address->id);
         $response = json_decode(Geocoder::geocode('json', ['address' => implode(' ', [$address->address_one, $address->address_two, $address->city, $address->state, $address->zip_code]), 'componets' => 'country:GB']));
         if ($response->status == 'OK') {
             $address->latitude = $response->results[0]->geometry->location->lat;
             $address->longitude = $response->results[0]->geometry->location->lng;
             // Figure out the city/state
             foreach ($response->results[0]->address_components as $addressParts) {
                 if (property_exists($addressParts, 'types') && is_array($addressParts->types)) {
                     if (in_array('administrative_area_level_1', $addressParts->types)) {
                         $address->state = $addressParts->short_name;
                     } elseif (in_array('locality', $addressParts->types)) {
                         $address->city = $addressParts->long_name;
                     }
                 }
             }
             // use township as the city
             if (strlen($address->city) == 0) {
                 foreach ($response->results[0]->address_components as $addressParts) {
                     if (property_exists($addressParts, 'types') && is_array($addressParts->types)) {
                         if (in_array('administrative_area_level_3', $addressParts->types)) {
                             $address->city = $addressParts->long_name;
                         }
                     }
                 }
             }
             $address->save();
             $this->delete();
         } elseif (DatabaseSeeder::isSeeding() === false && app()->environment('testing') === false) {
             Log::error('Problematic response from GMaps', ['address' => $address, 'response' => (array) $response]);
         }
     } catch (\RuntimeException $e) {
         //ignore failures if we're local.
         //useful when seeding and not on the internet
         if (DatabaseSeeder::isSeeding() || App::environment('local', 'testing') && $e->getMessage() == 'cURL request retuened following error: Could not resolve host: maps.googleapis.com') {
             Log::debug('Suppressing error when fetching coordinates for address');
             return;
         }
         throw $e;
     }
 }
Ejemplo n.º 6
0
 /**
  * @test
  */
 public function associateWithExistingUserIfEmailAddressMatches()
 {
     $firstName = 'Jane';
     $lastName = 'Lork';
     //allow GUID to be set
     User::unguard();
     User::create(['guid' => md5(uniqid() . microtime()), 'email' => $this->providerUser->getEmail(), 'first_name' => $firstName, 'last_name' => $lastName, 'primary_address_id' => Address::firstOrFail()->id]);
     User::reguard();
     $this->call('GET', '/login/' . ThirdPartyAuthenticator::PROVIDER_GOOGLE, ['code' => uniqid()]);
     // logged in as pre-existing user
     $this->followRedirects()->see($firstName . ' ' . $lastName);
     //assert user was not created
     $name = explode(' ', $this->providerUser->getName());
     $createdUser = User::where('first_name', $name[0])->where('last_name', $name[1])->where('email', $this->providerUser->getEmail())->where('avatar', $this->providerUser->getAvatar())->count() > 0;
     $this->assertFalse($createdUser);
 }
Ejemplo n.º 7
0
 /**
  * @return mixed
  */
 public function postSetup(Request $request, Scrubber $scrubber)
 {
     $request->merge(['name' => 'Home', 'phone' => $scrubber->integer($request->get('phone'))]);
     $userRules = array_only(User::validationRules(), ['gender', 'phone', 'first_name', 'last_name']);
     $this->validate($request, array_merge(Address::validationRules(), $userRules), Address::validationMessages());
     //update the info
     DB::transaction(function () use($request) {
         $user = Auth::user();
         $user->first_name = $request->get('first_name');
         $user->last_name = $request->get('last_name');
         $user->phone = $request->get('phone');
         $user->gender = $request->get('gender');
         $user->save();
         // set timezone
         $settings = $user->settings;
         $settings->setTimezone($request->input('timezone'));
         $user->update(['settings' => $settings]);
         // add user address
         $address = App::make(Address::class, [$request->except(['first_name', 'last_name', 'phone', 'gender', 'timezone', 'answer', 'other'])]);
         $user->addresses()->save($address);
         $user->update(['primary_address_id' => $address->id]);
         // record survey
         if ($request->has('answer') && count($request->get('answer')) > 0) {
             $surveys = [];
             foreach ($request->get('answer') as $questionId => $answers) {
                 foreach ($answers as $answerId => $true) {
                     $surveys[] = app(RegistrationSurvey::class, [['answer_id' => $answerId]]);
                 }
                 // update that question's "Other"
                 if ($request->has('other.' . $questionId) && strlen($request->get('other')[$questionId]) > 0) {
                     $otherAnswer = RegistrationSurveyAnswer::where('question_id', $questionId)->where('answer', 'Other')->first();
                     $surveys[] = app(RegistrationSurvey::class, [['answer_id' => $otherAnswer->id, 'other' => $request->get('other')[$questionId]]]);
                 }
             }
             $user->surveys()->saveMany($surveys);
         }
     });
     return redirect('/dashboard');
 }
@extends('emails.simple')

@section('body')
    <?php 
// Serialized objects need to be re-instantiated in order
// to have a successful database connection
$primaryAddress = \BibleBowl\Address::findOrFail($guardian['primary_address_id']);
$group = \BibleBowl\Group::findOrFail($groupId);
$playerCount = count($players);
?>

    @if ($hasEmailBody)
        @include('emails.theme.text-block', [
            'body' => $emailBody
        ])

        @include('emails.theme.empty-spacer')
    @endif

    @include('emails.theme.header', [
        'header' => 'Registration Confirmation'
    ])

    <table cellpadding="0" cellspacing="0" bgcolor="#f4f4f4" border="0">
        <tr>
            <!--=========== JUST ENTER YOUR INFO HERE =========-->
            <td valign="middle" bgcolor="#f4f4f4" height="10" class="sectionRegularInfoTextTD" style="border-collapse: collapse;color: #42484c;font-family: Arial, Tahoma, Verdana, sans-serif;font-size: 13px;font-weight: lighter;padding: 0;margin: 0;text-align: left;line-height: 165%;letter-spacing: 0;">

                @include('emails.theme.text-block', [
                    'body' => 'Please double check the below information to ensure everything is correct.  If you find a mistake, you can '.EmailTemplate::link(url('login'), 'login to your Bible Bowl account').' and correct the mistake.'
                ])
Ejemplo n.º 9
0
 public static function validationRules($groupAlreadyExists = false)
 {
     // Check to see if a group is a duplicate by looking at the location where they meet (zip code or city/state
     // and their program/name when the group is created
     Validator::extend('isnt_duplicate', function ($attribute, $value, $parameters, $validator) {
         $meetingAddress = Address::findOrFail($validator->getData()['meeting_address_id']);
         $group = Group::where('name', $value)->where('program_id', $validator->getData()['program_id'])->whereHas('meetingAddress', function ($query) use($meetingAddress) {
             $query->orWhere(function ($query) use($meetingAddress) {
                 $query->where('city', '=', $meetingAddress->city);
                 $query->where('state', '=', $meetingAddress->state);
             })->where('zip_code', '=', $meetingAddress->zip_code);
         })->first();
         return is_null($group);
     });
     return ['name' => 'required|max:128' . ($groupAlreadyExists ? '' : '|isnt_duplicate'), 'program_id' => 'required', 'owner_id' => 'required|exists:users,id', 'address_id' => 'required|exists:addresses,id'];
 }
Ejemplo n.º 10
0
 /**
  * @param AddressOwnerOnlyRequest $request
  * @param                         $id
  *
  * @return mixed
  */
 public function destroy(AddressOwnerOnlyRequest $request, $id)
 {
     $address = Address::find($id);
     $address->delete();
     return redirect('/account/address')->withFlashSuccess('Your ' . $address->name . ' address has been deleted');
 }
 public function messages()
 {
     return array_merge(['first_name.required_unless' => 'The first name field is required', 'last_name.required_unless' => 'The last name field is required', 'email.required_unless' => 'The email field is required', 'gender.required_unless' => 'The gender field is required', 'address_one.required_unless' => 'The street address field is required', 'zip_code.required_unless' => 'The zip code field is required', 'spouse_gender.required' => "Your spouse's gender is required", 'spouse_shirt_size.required' => "Your spouse's shirt size is required"], Address::validationMessages());
 }
Ejemplo n.º 12
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Address::where('id', $this->route('address'))->where('user_id', Auth::id())->exists();
 }
Ejemplo n.º 13
0
 /**
  * @param array $attributes
  *
  * @return static
  */
 public function create(array $attributes)
 {
     // coordinates are fetched via model events
     return Address::create($attributes);
 }