wxcaptain

wxcaptain

Member Since 7 Months Ago

Experience Points
940
Total
Experience

4,060 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
5
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 1
940 XP
Aug
27
2 months ago
Activity icon

Started a new Conversation Service Worker - Cache Name Looks Different

I just started using laravel mix to generate a service worker file. I noticed that the query string on the application cache name is different than the query string on the resource.

As an example, here's a css file with a revision id: about.css?id=027cd1716bb5f6288ed0

In chrome dev tools, the application name looks like this: about.css?WB_REVISION=027cd1716bb5f6288ed032926f5da1de

I have some non pre-cached images that I can tell are getting loaded from the service worker, using the Chrome dev tools network tab, but I'm not seeing this with the about.css.

Do you think this about.css file is getting cached appropriately by the service worker?

Thanks.

Aug
26
2 months ago
Activity icon

Awarded Best Reply on Mail From Address - Gmail Alias - Not Working

OMG... I was mispelling the MAIL_FROM_ADDRESS... Mystery solved. Thanks @ravish for your suggestions!

Activity icon

Replied to Mail From Address - Gmail Alias - Not Working

OMG... I was mispelling the MAIL_FROM_ADDRESS... Mystery solved. Thanks @ravish for your suggestions!

Activity icon

Replied to Mail From Address - Gmail Alias - Not Working

Ah! It looks like it is on the application side. I'm using a Notification to send the email, and when I specified the from property on the MailMessage, it worked, but if I rely on the environmental variable MAIL_FROM_ADDRESS and don't specify the from property, then it doesnt work.

This works:

        return (new MailMessage)
            ->from('[email protected]', 'FROM NAME')
            ->replyTo($this->email, $this->name)
            ->subject('Contact Form')
            ->line('Name: '.$this->name)
            ->line('Email: '.$this->email)
            ->line('Message: '.$this->message);

This does not work:

        return (new MailMessage)
            ->replyTo($this->email, $this->name)
            ->subject('Contact Form')
            ->line('Name: '.$this->name)
            ->line('Email: '.$this->email)
            ->line('Message: '.$this->message);
Activity icon

Replied to Mail From Address - Gmail Alias - Not Working

Thanks @ravish I have configured gmail, and even got confirmation from the gmail rep that it was configured correctly, but for some reason, its still not working.

I took a look at the message listener, and the FROM address, appears to be the way I want it, when the message goes out, so it does appear that everything is the way its supposed to be on the application side.

Aug
25
2 months ago
Activity icon

Started a new Conversation Mail From Address - Gmail Alias - Not Working

I am sending smtp mail through gmail, and using a registered alias FROM address, but it shows up as the FROM address of the account and not the alias address. According to the Google rep, there should be no reason, I can't send the mail through the alias address. Is this a Laravel issue?

[email protected] [email protected] MAIL_FROM_NAME="Domain"

The From Domain works, but the the FROM address reverts to the username address, rather than the FROM address. Any thoughts on this?

Thanks.

Aug
20
2 months ago
Activity icon

Replied to Cashier New Subscription Using Coupon Promotional Code

Thank you for this! Since, may subscriptions have 14 day trial periods, I think retroactively updating will be fine in my case. However, your right, if there wasn't the trial period, I would have to override the classes.

Activity icon

Replied to Cashier New Subscription Using Coupon Promotional Code

Looks like answer was at the bottom of the Cashier documentation:

Many of Cashier's objects are wrappers around Stripe SDK objects. If you would like to interact with the Stripe objects directly, you may conveniently retrieve them using the asStripe method:

$stripeSubscription = $subscription->asStripeSubscription();

$stripeSubscription->update($subscription->stripe_id, ['application_fee_percent' => 5]);

Looks like, all i have to do is instead of passing 'application_fee_percent', I can pass 'promotional_code'. Looks easy enough.

Activity icon

Replied to Cashier New Subscription Using Coupon Promotional Code

This is how the call currently looks with applying the coupon code:

            $return['success'] = ($this->user->newSubscription('pro', $planId)
                ->trialDays(config('services.subscription.trial_days'))
                ->withCoupon($request->couponCode)
                ->create($request->payment_method)) ? true : false;

the newSubscription method is from the Billable trait:

    public function newSubscription($subscription, $plan)
    {
        return new SubscriptionBuilder($this, $subscription, $plan);
    }

The SubscriptionBuilder() is on SubscriptionBuilder class.

It looks like I just need to add a property on to the SubscriptionBuilder create():

    public function create($paymentMethod = null, array $options = [])
    {
        $customer = $this->getStripeCustomer($paymentMethod, $options);

        /** @var \Stripe\Subscription $stripeSubscription */
        $stripeSubscription = $customer->subscriptions->create($this->buildPayload());

        if ($this->skipTrial) {
            $trialEndsAt = null;
        } else {
            $trialEndsAt = $this->trialExpires;
        }

        /** @var \Laravel\Cashier\Subscription $subscription */
        $subscription = $this->owner->subscriptions()->create([
            'name' => $this->name,
            'stripe_id' => $stripeSubscription->id,
            'stripe_status' => $stripeSubscription->status,
            'stripe_plan' => $this->plan,
            'quantity' => $this->quantity,
            'trial_ends_at' => $trialEndsAt,
            'ends_at' => null,
        ]);

        if ($subscription->incomplete()) {
            (new Payment(
                $stripeSubscription->latest_invoice->payment_intent
            ))->validate();
        }

        return $subscription;
    }

Via the stripe api docs, I just need to pass the "promotional_code" property. I'm just not sure, how I go about modifying in my app.

Activity icon

Started a new Conversation Cashier New Subscription Using Coupon Promotional Code

Hi,

The documentation shows how to create a new subscription using the method withCoupon(). With Stripe, however, a coupon, can have multiple promotional codes, so I'd like the user to apply the promotional code, rather than simple the coupon id.

I'm using 6.x. It doesn't look like cashier has the method to apply promotional codes, so I was wondering how to add on to the newSubscription() and add a withPromoCode() method.

Thanks for any suggestions.

Jun
29
3 months ago
Activity icon

Replied to Redirect Going To Http Not Https

Hmm, okay Snapey, I guess I need to find out what poxy is being used.

Activity icon

Replied to Redirect Going To Http Not Https

Thanks for the reply Snapey. I don't believe I"m behind a proxy. I'm using an AWS Lightsail server, and just for fun I added the server IP to the trusted proxies without any changes.

Activity icon

Replied to Redirect Going To Http Not Https

I was able to get around this problem, by making the redirect like this:

        return redirect()->to(env('APP_URL').'/login/ajax?email='.urlencode($request->email).'&password='.urlencode($request->password).'&register_form=true');

By redirecting to the full URL, it maintained the https status. Still not sure, why it didn't maintain the https domain with the basic redirect routing, but this solution got the job done for me.

Activity icon

Replied to Redirect Going To Http Not Https

Why do you say POST routes do not work well with controller actions?

And, why does it matter that I'm just returning a json response.

I have yet to find a logical reason why its redirecting to http, and not https.

Jun
28
4 months ago
Activity icon

Replied to Redirect Going To Http Not Https

If the password is incorrect after the redirect to the login controller, then it will just return the login error. The form is setup to easily switch between register/login.

Here's the loginAjax function, but I don't think this will get at the problem of solving why the redirect from registerAjax to loginAjax is going to http instead of https:

    public function loginAjax(Request $request) {

        $responseData = array();
        if ($request->register_form)
            $responseData['loginFromRegister'] = true;

        //if email does not exist, push over to register form
        if (!User::where('email',$request->email)->first()) {
            $responseData['errorMsg'] = 'An account with this email address does not exist. Please register a new account';
            $responseData['sendToRegister'] = true;
            return response()->json($responseData);
        }


        //validate email and password
        $validator = Validator::make($request->all(), [
            'email' => 'bail|required|email|string',
            'password' => 'required|min:8',
        ]);

        if (! $validator->passes()) {
            $responseData['errorMsg'] = $validator->errors()->first();
            return response()->json($responseData);
        }

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if (method_exists($this, 'hasTooManyLoginAttempts') &&
            $this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            $responseData['errorMsg'] = 'Too many log in attempts. Try again in '.$this->decayMinutes.' minutes';
            return response()->json($responseData);
        }

        if ($this->attemptLogin($request)) {

            $request->session()->regenerate();
            $this->clearLoginAttempts($request);

            $user = User::where('email',$request->email)->first();
            $subscription = ($user->subscribed('pro')) ? 'pro' : 'basic';

            $responseData['errorMsg'] = '';
            $responseData['subscription'] = $subscription;
            return response()->json($responseData);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

        if ($request->register_form)
            $responseData['errorMsg'] = 'This email account already exists, but the password is incorrect. Try signing in with different password.';
        else
            $responseData['errorMsg'] = 'Incorrect email/password. Try again.';
        return response()->json($responseData);
    }

Thanks for your thoughts.

Activity icon

Replied to Redirect Going To Http Not Https

Here's the situation, If someone who is already registers, fill out the register form (and not the login form), I want to redirect the request over to the login controller and just log the user in.

I have routes for both the register and login requests.

Route::post('/register/ajax','Auth\[email protected]'); Route::post('/login/ajax','Auth\[email protected]')->name('login-ajax');

Here's the RegisterController logic to redirect:

    public function registerAjax(Request $request)
    {
        //if the email already exists, send to login
        if (User::where('email',$request->email)->first()) {
            return redirect()->action('Auth\[email protected]',['email' => $request->email, 'password' => $request->password, 'register_form' => true]);
            //return redirect()->route('login-ajax',['email' => $request->email, 'password' => $request->password, 'register_form' => true]);
        }

Using axios for ajax call, pretty straight forward sending email and password in data params:

                    axios({
                        method: 'post',
                        url: '/register/ajax',
                        headers: {'X-CSRF-TOKEN': window.SC.csrfToken},
                        data: params,
                    })

If you have any suggestions, I would appreciate them. Thanks.

Activity icon

Started a new Conversation Redirect Going To Http Not Https

Hi, I have an ajax request coming into the server as an https request, and then I redirect it to a controller action. The problem is that the redirect goes to http, not https, and I then I get a javascript fail, from requesting an http resource from an https site.

Any ideas of why it is redirecting to http, and not https? May App_URL in my .env file, has the domain as https.

Here is my redirect: return redirect()->action('Auth\[email protected]',['email' => $request->email, 'password' => $request->password, 'register_form' => true]);

I'm using Laravel 6.x.