lukegalea16

lukegalea16

Member Since 2 Months Ago

Experience Points 640
Experience Level 1

4,360 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

29 Aug
2 weeks ago

lukegalea16 left a reply on Scheduler/Event Listener

Yes something automated - I want to send an SMS for users whose subscription has expired.

lukegalea16 started a new conversation Scheduler/Event Listener

I have a list of users that need to renew their subscription before they can access the database. In a particular table I have an expiry date. Is there a way to schedule an event or job which carries out a task (send sms) whenever the expiry date for such users is greater than the current date/time. I think I'd need some process that runs in the background?

13 Aug
1 month ago

lukegalea16 left a reply on Eloquent Relationships Vs Where:: Query

Yes that's right :) Relationships are more comfortable/elegant - just wanted to make sure that there's nothing technically wrong about using where::

Thanks!

lukegalea16 left a reply on Eloquent Relationships Vs Where:: Query

@ftiersch - you are right, however kind of both can be used I think. For example technically I can fetch the user ID and then use the where command in the posts table to fetch the posts belonging to that user ID.

lukegalea16 started a new conversation Eloquent Relationships Vs Where:: Query

So basically to query my database tables I got used to using the where:: method instead of defining relationships in the model and using those methods to query the database. Would this be a matter of preference or are there advantages to using relationships instead of the where:: method? Thanks!

07 Aug
1 month ago

lukegalea16 left a reply on Request Cookie

Removed the AJAX form and am using a standard HTML form and the cookie is now being set...

06 Aug
1 month ago

lukegalea16 left a reply on Request Cookie

Further update... I cleared the cookie stored in Chrome and it is not being set/stored however it is being set in Postman...

lukegalea16 left a reply on Request Cookie

Hi, my other method for setting/saving a cookie is the following:

$cookie = cookie('auth_token', $randomtoken, '43800');  //approx 1 month in minutes

if($saved){
    return response()->json([
        'message' => 'Access granted, Cookie issued',
                'status' => 'ACCESS',
                'access_token' => $token->token,
                'token_type' => 'Bearer'
    ], 200)->cookie($cookie);
}

When I look into the cookies of my browser I can also see the cookie saved, so I am clueless to why it is not being retrieved...

lukegalea16 started a new conversation Request Cookie

I have the following code in a login API which reads the cookie (if available/stored):

$value = $request->cookie('auth_token');
if(isset($value)){
    return response()->json([
        'message' => 'Cookie Found',
                'status' => 'COOKIE'
    ], 200);
}

When testing it in POSTMAN, the cookie is read/found; however when testing it in a browser - the cookie is not read and then another part of the code comes into effect where a new cookie is issued.

Is this the correct way to read a cookie?

02 Aug
1 month ago

lukegalea16 left a reply on Email - Connection Refused #111

@ralee where did you setup the sendmail for office365 then please? I am using sendgrid instead - if I use sendmail instead of smtp how can I specify the host

lukegalea16 started a new conversation Laravel Mail - GoDaddy

Hi I have followed this guide: https://sendgrid.com/docs/for-developers/sending-email/laravel/

and successfully sent e-mails when the project was hosted locally. Then all stopped working when I hosted the project on GoDaddy - I keep getting a 500 Server Error and I was informed to add Sender Authentication. I have done this (add CNAME records to DNS Management) but the problem persists.

The error from the Laravel log is: [2019-08-02 11:37:36] production.ERROR: Connection could not be established with host smtp.sendgrid.net [Connection refused #111] {"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host smtp.sendgrid.net [Connection refused #111] at /.../vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:269)

Upon contacting GoDaddy they told me that such SMTP requests cannot be sent because my server is shared not VPS/Dedicated Server Plan.

Has anyone experienced this before?

lukegalea16 left a reply on How Can I Solve "Connection Could Not Be Established With Host Smtp.gmail.com"?

I am suffering from the same issue as @moses - Laravel Mailing works on my local host but not when the project is hosted on GoDaddy - any answers please?

22 Jul
1 month ago

lukegalea16 started a new conversation Storing Bearer Tokens From The User's End

I have successfully managed to create registration and login API routes in Laravel where a bearer token is issued when the user successfully logs in. The user may then use said bearer token to access his/her information and logout and so the user and logout routes are protected by authorization header middleware. For now I have tested these APIs using postman. For the actual implementation, when a user successfully logs in - where should the bearer token be stored (cookies perhaps?) in order for the user's session to pass the bearer token and access other pages with his/her information? Moreover how could a remember me method be implemented? and should refresh tokens be implemented? In order to eliminate cases where the user is logged out during a session if the token expires.

Tia!!

19 Jul
1 month ago

lukegalea16 left a reply on Swift_TransportException When Sending E-mail

However, just in case an exception happens how can I catch it and do something else?

lukegalea16 left a reply on Swift_TransportException When Sending E-mail

Turns out I exceeded the daily limit on Sendgrid.

lukegalea16 started a new conversation Swift_TransportException When Sending E-mail

I am successfully sending e-mails from a controller in Laravel, however randomly or once in a while I get the following error in postman: Swift_TransportException: Failed to authenticate on SMTP server with username "iotsolutions" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 250 but got an empty response. I am using Sendgrid as my e-mail client - perhaps I could catch the exception and re-send the e-mail? Any ideas?

Thanks!

16 Jul
2 months ago

lukegalea16 left a reply on Call Controller Function From Another Controller

Hi @cronix thank you for that ! I am still not sure whether traits are the way to go in my case since the methods only have like two lines in common, so there is not much repetition I think

15 Jul
2 months ago

lukegalea16 left a reply on Call Controller Function From Another Controller

@cronix so then in the api route where I'm calling the controller, I would call these two methods instead?

lukegalea16 left a reply on Call Controller Function From Another Controller

@cronix ok, but how would I then go about calling the two methods? to save to either tables

lukegalea16 left a reply on Call Controller Function From Another Controller

@martinbean would you suggest using redirection or a service class?

lukegalea16 left a reply on Call Controller Function From Another Controller

I have experience with coding but I'm still getting used to the Laravel framework, in this case should I redirect to another controller action or implement the logic (including saving to a table) in a generic service class? Why should I choose either option?

lukegalea16 left a reply on Call Controller Function From Another Controller

Thank you all for your replies, basically after saving my $Request to a particular table, i want to take a particular field of $Request and decode it and store the result in another table. Hence after successfully saving the raw $Request to the device_data_messages table, I want to point to another controller (or action) which would then decode the $Request and store the result in another table.

lukegalea16 started a new conversation Call Controller Function From Another Controller

Knowing that calling a controller function from another function is not good practice for Laravel, I tried adding a service which can be used to call another function from another controller, however it is not working as expected.

<?php

namespace App\Http\Controllers\api\v1;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services;

//Import models
use App\device_data_message;
use App\device_geo_message;
use App\decoded_data_message;

//This controller handles incoming callbacks/messages - currently from SIGFOX only
class CallbackController extends Controller
{

public function sigfoxstore(Request $Request)
    {                 
        if ($Request->has('data')) {
            $device_data_message = new device_data_message();
            $device_data_message->device = request('device');
            $device_data_message->seqNumber = request('seqNumber');
            $device_data_message->data = request('data'); 
            $device_data_message->bsId = '0';
            $device_data_message->nbRep = '0';
            $device_data_message->snr = '0';
            $device_data_message->rssi = '0';
            $saved = $device_data_message->save();
            $this->decodedDataMessageService->store($Request);
            if($saved){
                echo json_encode(array());
            }            
        }
}

In app\Services I created the following...

<?php 

namespace App\Services;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\data_decoding\v1\DecodedDataMessageController;

//Import models
use App\device_data_message;
use App\device_geo_message;
use App\decoded_data_message;

public function store(Request $Request)
{
   this->DecodedDataMessageController->dataparsingstore($Request);
   echo json_encode(array()); 
}

?>

After saving to device_data_message, I wish to pass the $Request to DecodedDataMessageController to save in another table and I tried to do so by adding a service in between.

12 Jul
2 months ago

lukegalea16 left a reply on Laravel Min Validation Not Working

Hi everyone, had a dumb thing going on - I'm versioning APIs and I forgot to route to the new API version.

Many thanks everyone.

lukegalea16 left a reply on Laravel Min Validation Not Working

Just tried 'data' => ['required','min:22', string] but it did not work

lukegalea16 left a reply on Laravel Min Validation Not Working

Sounds probable! To force Laravel to treat the request as a string could I use string instead? Since data is expected to be a string

lukegalea16 left a reply on Laravel Min Validation Not Working

Will try that thanks!

lukegalea16 left a reply on Laravel Min Validation Not Working

Allow me to rephrase... If I set the device min for 6 and max for 8 then if I pass a string of 2 characters long, an error should be returned, no? Since the string must be of length between 6 and 8

lukegalea16 left a reply on Laravel Min Validation Not Working

I had taken them from them however neither of those rules work... the min still doesn't work

lukegalea16 left a reply on Laravel Min Validation Not Working

What do you mean? If my min is 6, I expect to have a minimum number of 6 characters else an error is returned (for device for example)

lukegalea16 left a reply on Laravel Min Validation Not Working

Thank you for your reply. I had tried that, and then changed it to $Request because of my function.

public function sigfoxstore(Request $Request)
    {        
        /*Save request to device_data_message if request has data parameter*/             
        if ($Request->has('data')) {
            $attributes = $Request->validate([
                'device' => 'required|string|digits_between:6,8', //ID is minimum of 6, maximum of 8
                'seqNumber' => ['required','numeric'],
                'data' => ['required','min:22']
            ]);
            $device_data_message = new device_data_message();
            $device_data_message = $attributes;
            $device_data_message->bsId = '0';
            $device_data_message->nbRep = '0';
            $device_data_message->snr = '0';
            $device_data_message->rssi = '0';
            $saved = $device_data_message->save();
            if($saved){
                echo json_encode(array());
            }            
        }
}

lukegalea16 started a new conversation Laravel Min Validation Not Working

I am trying to validate a request as shown below and the max is working well, however if I enter a string of 2 characters for the device and data, it is still accepted and no error is returned.

if ($Request->has('data')) {
            $attributes = $Request->validate([
                'device' => 'required|string|min:6|max:8', //ID is minimum of 6, maximum of 8
                'seqNumber' => ['required','numeric'],
                'data' => ['required','min:22']
            ]);
            $device_data_message = new device_data_message();
            $device_data_message = $attributes;
            $device_data_message->bsId = '0';
            $device_data_message->nbRep = '0';
            $device_data_message->snr = '0';
            $device_data_message->rssi = '0';
            $saved = $device_data_message->save();
            if($saved){
                echo json_encode(array());
            }            
        }