jaydubyasee

jaydubyasee

Member Since 1 Year Ago

Experience Points 13,620
Experience
Level
Lessons Completed 134
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Oct
1 month ago

jaydubyasee left a reply on Testing A Random Field

@D9705996 Thanks for this but how does this affect the test? I can see that the stub contains the "Day" each time but my test still randomly generates a select box containing either days, months or years. How does the stub get incorporated into the assertion?

10 Oct
1 month ago

jaydubyasee left a reply on Testing A Random Field

@D9705996 The form is for members whose data we already hold so we already know the date of birth and can check what the member enters matches our records.

As for a test for each mechanism - that's just the issue. When running a browser test, in order for the test to pass, I need the test to select the correct day/month/year matching the test user that I create but the browser test doesn't know whether to enter the day, month or year.

    /**
     * @test
     */
    public function DOB_must_match_database()
    {
        factory(Member::class)->create([
            'confirmation_code' => '123456789',
            'dob'               => '25/04/1966',
            'niNumber'          => 'DB123455E',
        ]);

        $this->visit('/register')
            ->type('123456789', 'confirmation_code')
            ->type('DB', 'niNumber')
            ->select('1966', 'dob')
            ->press('Continue')
            ->see('Register (Page 2)');
    }

This will only work if the system has chosen "YEAR" as the field to prompt for otherwise the test will fail.

jaydubyasee started a new conversation Testing A Random Field

I have a registration form which prompts the user to enter either their day, month or year of birth. The choice of day/month/year is randomly decided by the controller each time the form loads. The system then uses this (along with other identifying information entered) to check the corresponding member record and display the next page in the registration process.

My problem is how to set up a test which simulates user input when I don't know which data item the system will ask for?

Controller

    public function showRegistrationForm()
    {
        $datePart = array_rand(['Day' => 'Day', 'Month' => 'Month', 'Year' => 'Year']);
        // random day, month or year
        $dateArray = Utils::getAllDaysMonthsYears($datePart);

        return view('auth.register')
            ->with('datePart', $datePart)
            ->with('dateArray', $dateArray);
    }

View

            <div class="form-group{{ $errors->has('dob') ? ' has-error' : '' }}">
                {{ Form::label('dob', "$datePart of birth", ['class' => ' control-label']) }}

                <div class="rounded-select dob">
                    {{Form::select('dob',
                    $dateArray,
                    old('dob'),
                    ['class' => 'form-control correct-drpdwn-height', 'required' => 'required', 'size' => 1])}}
                    {{ Form::hidden(
                        'dobPart',
                        $datePart
                        )
                    }}
                </div>

                @if ($errors->has('dob'))
                    <span class="help-block">
                        <strong>{{ $errors->first('dob') }}</strong>
                    </span>
                @endif

            </div>
03 Jul
4 months ago

jaydubyasee left a reply on PhpStorm Initialize Fields

It is possible to change the default from private.

Project Settings (Ctrl + Alt + S) => Editor => Code Style => PHP => Code Generation tab => Fields Default Visibility.

30 May
5 months ago

jaydubyasee left a reply on VS Code Xdebugging Throws DecryptException: The Payload Is Invalid.

I get the same problem and although I don't know what's generating the exception I was able to suppress the debugger reporting it by making sure the "Everything" checkbox is clear in the debugger breakpoints.

09 May
1 year ago

jaydubyasee left a reply on Eloquent "where" Not Working

Okay, gave up trying to understand the problem. Changed the Utils::generateRandomString(); function generate a more random string and now I get no duplicate with 30,000 records.

jaydubyasee left a reply on Eloquent "where" Not Working

Yup tried that as well. No luck. Should have mentioned that I've tried:

$member = Member::where('confirmation_code', $confirmationCode)->first();
$member = Member::where('confirmation_code', '=', $confirmationCode)->first();
$member = Member::where('confirmation_code', '=', $confirmationCode)->get();

Also tried with and without unset($member). It just seems that $member->isEmpty() is true whether Member::where(...) finds an entry on the db or not.

jaydubyasee left a reply on Eloquent "where" Not Working

I had first() originally but it didn't work either. I changed it to get() to see if the first() was the problem.

08 May
1 year ago

jaydubyasee started a new conversation Eloquent "where" Not Working

I'm trying to generate an 8 character random unique reference code.

My seeder is calling this function

    public static function generateUniqueConfirmationCode()
    {
        $found = false;
        $confirmationCode = '';
        while (!$found) {
            unset($member);
            $confirmationCode = Utils::generateRandomString();
            $member = Member::where('confirmation_code', $confirmationCode)->get();
            if ($member->isEmpty()) {
                $found = true;
            } 
        }

        return $confirmationCode;
    }

but the Member::where('confirmation_code', $confirmationCode)->get() line is not finding if the confirmation code already exists on the table and as a result duplicates are being created.