tjsherrill

tjsherrill

Member Since 2 Years Ago

Experience Points
14,020
Total
Experience

980 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
136
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 3
14,020 XP
Jul
09
2 months ago
Activity icon

Started a new Conversation Laravel Nova Custom View With Table From Db Table

I use a Laravel package for keeping an auth log. https://github.com/yadahan/laravel-authentication-log

It is a great package and I have used it on multiple platforms. I have it on a new platform but I am using Nova for the admin instead of writing an admin from scratch.

This auth log is a clean db table that I want to be able to display in Nova's clean table layout. The auth log table has an id relation to a user id.

How can I show this db table in a clean nova table on its own page in Nova?

TIA

Jun
09
3 months ago
Activity icon

Replied to Ajax Submission Creates Object And Returns A 422

I was able to sort this out after realizing that some middleware was likely returning $next. Did some looking and found a middleware was looping back around on the request.

Thanks for the help.

Activity icon

Replied to Ajax Submission Creates Object And Returns A 422

Thanks for the idea. I have updated that and still have the same issue. Interestingly I updated the code in both the REquest and the Controller to look like this:

public function rules()
    {
        if($this->app_key){ 
            Log::info('in the if');
          return [
                'name'              => 'required',
                'address_street'    => 'required',
                'address_city'      => 'required',
                'address_state'     => 'required',
                'address_postcode'  => 'required',
                'address_country'   => 'required',
                'email'             => 'required|email|confirmed',
                'company_name'      => 'required',
                'title'             => 'required',
                'referred_by'       => 'required',
                'referred_method'   => 'required',
            ];
        } else {
            Log::info('in the else ');
            return [
                'name'              => 'required',
                'address_street'    => 'required',
                'address_city'      => 'required',
                'address_state'     => 'required',
                'address_postcode'  => 'required',
                'address_country'   => 'required',
                'email'             => 'required|email|confirmed|unique:App\User,email',
                'password'          => 'required|confirmed',
                'company_name'      => 'required',
                'title'             => 'required',
                'referred_by'       => 'required',
                'referred_method'   => 'required',
            ];
        } // end if app key
    }

and the controller:

  public function stepOneSubmit(ApplicationPageOne $request, $key = null)
    {
        Log::info('start controller');
        if ($request->app_key) {  // Update the user
            $user = User::where('application_key', $request->app_key)->first();

            $user->update([
                'name'              => $request->name,
                'address_street'    => $request->address_street,
                'address_street_two' => $request->address_street_two,
                'address_city'      => $request->address_city,
                'address_state'     => $request->address_state,
                'address_postcode'  => $request->address_postcode,
                'address_country'   => $request->address_country,
                'email'             => $request->email,
                'company_name'      => $request->company_name,
                'title'             => $request->title,
                'referred_by'       => $request->referred_by,
                'referred_method'   => $request->referred_method,
            ]);
        } else { // Create the user
            $user = User::create([
                'name'              => $request->name,
                'address_street'    => $request->address_street,
                'address_street_two' => $request->address_street_two,
                'address_city'      => $request->address_city,
                'address_state'     => $request->address_state,
                'address_postcode'  => $request->address_postcode,
                'address_country'   => $request->address_country,
                'email'             => $request->email,
                'password'          => Hash::make($request->password),
                'company_name'      => $request->company_name,
                'title'             => $request->title,
                'referred_by'       => $request->referred_by,
                'referred_method'   => $request->referred_method,
            ]);

            // Handle Application Key
            $user->role_id = 10;
            $user->application_step_completed = 1;
            $user->application_key = bin2hex(openssl_random_pseudo_bytes(20));
        } // Endif key
    
        // Handle optional affiliation disclaimer
        if ($request->affiliation_disclaimer) {
            $user->affiliation_disclaimer = $request->affiliation_disclaimer;
        } else {
            $user->affiliation_disclaimer = 0;
        }

        $ac = new ActiveCampaign;
        $acUser = $ac->addUserToAC($user);
        if ($acUser['result_code'] == 1) {
            $user->active_campaign_id = $acUser['subscriber_id'];
        } elseif ($acUser['result_code'] == 0) {

            $user->active_campaign_id = $acUser[0]['id'];
        }

        $user->save();
        Log::info('saved user');
        // Member Correct Tag based on Application type
        if ($request->referred_by == 'Member') {
            $this->createReferral($user);
        }

        return json_encode($user->application_key);
    }

When I run the application again I get the following in the log:

[2020-06-09 17:45:00] local.INFO: in the else   
[2020-06-09 17:45:00] local.INFO: start controller  
[2020-06-09 17:45:01] local.INFO: saved user  
[2020-06-09 17:45:01] local.INFO: in the else   

Why would it log out the "in the else" a second time?

Jun
08
3 months ago
Activity icon

Started a new Conversation Ajax Submission Creates Object And Returns A 422

I have a application view for my web app. A user applies and then is approved or rejected. I just updated to L7 and it is both creating a user and returning a 422. The flow is View => Custom Request => Controller.

My custom request rules:

public function rules()
    {
        if($this->app_key){ 
          return [
                'name'              => 'required',
                'address_street'    => 'required',
                'address_city'      => 'required',
                'address_state'     => 'required',
                'address_postcode'  => 'required',
                'address_country'   => 'required',
                'email'             => 'required|email',
                'email_confirm'     => 'required|same:email|email',
                'company_name'      => 'required',
                'title'             => 'required',
                'referred_by'       => 'required',
                'referred_method'   => 'required',
            ];
        } else {
            return [
                'name'              => 'required',
                'address_street'    => 'required',
                'address_city'      => 'required',
                'address_state'     => 'required',
                'address_postcode'  => 'required',
                'address_country'   => 'required',
                'email'             => 'required|email|unique:users',
                'email_confirm'     => 'required|same:email|email',
                'password'          => 'required',
                'password_confirm'  => 'required|same:password',
                'company_name'      => 'required',
                'title'             => 'required',
                'referred_by'       => 'required',
                'referred_method'   => 'required',
            ];
        } // end if app key
    }

followed by the controller action:

 public function stepOneSubmit(ApplicationPageOne $request, $key = null)
    {

       if($request->app_key){  // Update the user
            $user = User::where('application_key', $request->app_key)->first();

            $user->update([
                'name'              => $request->name,
                'address_street'    => $request->address_street,
                'address_street_two' => $request->address_street_two,
                'address_city'      => $request->address_city,
                'address_state'     => $request->address_state,
                'address_postcode'  => $request->address_postcode,
                'address_country'   => $request->address_country,
                'email'             => $request->email,
                'company_name'      => $request->company_name,
                'title'             => $request->title,
                'referred_by'       => $request->referred_by,
                'referred_method'   => $request->referred_method,
            ]);
        } else { // Create the user
            $user = User::create([
                'name'              => $request->name,
                'address_street'    => $request->address_street,
                'address_street_two' => $request->address_street_two,
                'address_city'      => $request->address_city,
                'address_state'     => $request->address_state,
                'address_postcode'  => $request->address_postcode,
                'address_country'   => $request->address_country,
                'email'             => $request->email,
                'password'          => Hash::make($request->password),
                'company_name'      => $request->company_name,
                'title'             => $request->title,
                'referred_by'       => $request->referred_by,
                'referred_method'   => $request->referred_method,
            ]);

            // Handle Application Key
            $user->role_id = 10;
            $user->application_step_completed = 1;
            $user->application_key = bin2hex(openssl_random_pseudo_bytes(20));
        } // Endif key
    
        // Handle optional affiliation disclaimer
        if($request->affiliation_disclaimer){
            $user->affiliation_disclaimer = $request->affiliation_disclaimer;
        } else {
            $user->affiliation_disclaimer = 0;
        }

        $ac = new ActiveCampaign;
        $acUser = $ac->addUserToAC($user);
        if($acUser['result_code'] == 1){
            $user->active_campaign_id = $acUser['subscriber_id'];
        } elseif($acUser['result_code'] == 0) {

            $user->active_campaign_id = $acUser[0]['id'];
        }

        $user->save();
        // Member Correct Tag based on Application type
        if ($request->referred_by == 'Member') {
            $this->createReferral($user);
        }

        return json_encode($user->application_key);
    }

I double-check my user database and fill the form using an email that is not in the database.

I click submit and it runs but returns a 422 saying the email is in use already. To make matters more confusing the user gets created in the db.

TIA I have been at this for hours.