lukegalea16

lukegalea16

Member Since 4 Months Ago

Experience Points
990
Total
Experience

4,010 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.

Level 1
990 XP
Oct
09
1 month ago
Activity icon

Replied to Laravel Scheduler

Ended up configuring it from cPanel itself since it was easier to do so!

Activity icon

Replied to Laravel Scheduler

That makes sense... I have difficulty registering the Cron Job on my GoDaddy server.

My Laravel project folder is located at public_html/project.

In that case should I run the following command: * * * * * php /public_html/project schedule:run 1>> /dev/null 2>&1

Because I am getting no output back and when running crontab -l I can see no tasks/jobs registered.

Activity icon

Replied to Laravel Scheduler

@sinnbeck What I meant is, say that I do not need the scheduler to run anymore. Do I just delete the call from the scheduler or do I need to remove the Cron job as well?

Thank you

Activity icon

Replied to Laravel Scheduler

protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
            DB::table('recent_users')->delete();
        })->daily();
    }

Instead of the DB::table('recent_users')->delete(); can I call a service class?

Activity icon

Replied to Laravel Scheduler

@sinnbeck After the cron job is run, can it be stopped then? Thank you

Activity icon

Replied to Laravel Scheduler

@sinnbeck Right, thank you! as for the scheduler, can it run a service instead of a command?

Activity icon

Started a new Conversation Laravel Scheduler

I am trying to get a Laravel Scheduler to work using the following guide: https://laravel.com/docs/5.7/scheduling

I understood the define schedule and creating a command part however, in order to start the Scheduler a Cron entry needs to be done? as follows: * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

If the scheduled task is to be run daily, what frequency should the Cron entry have? To me it seems like a duplicate entry since I would have already specified the frequency of the job in the Laravel Kernel.

Oct
07
1 month ago
Activity icon

Replied to PHP Require Autoload

Seems to be an issue when working on a folder which is in OneDrive...

Activity icon

Replied to PHP Require Autoload

@geowrge yeah I assumed that tbh and because coincidentally I had Windows updates last Friday... Made sure that files are not set to Read-Only... will have to check again or copy the folder to another directory

Activity icon

Replied to PHP Require Autoload

@resin I am in the root directory where there are folders such as public, vendor, routes, etc. So the composer.json file should be found

Activity icon

Started a new Conversation PHP Require Autoload

So, I have a good and stable Laravel project running and I went to add a new migration but I keep getting the following errors:

PHP Warning: require(...vendor/autoload.php): failed to open stream: No such file or directory...

If I run composer update then I get the following error:

Composer could not find a composer.json file in...

However I have a composer.json file in my directory ...

Anyone encountered this issue before?

Sep
30
1 month ago
Activity icon

Replied to Storing Auth Tokens

@bobbybouwmann thank you for your reply :) just wanted to make sure that I am on the right track!

Sep
27
1 month ago
Activity icon

Started a new Conversation Storing Auth Tokens

I would like to create a users system where if the Login Credentials are successful, the user is granted access to his resources for a 30-day period (in order to eliminate the use of refresh tokens and have a 'Remember Me' feature). In order to access his/her data, a token is usually issued which is then passed to Laravel's Middleware to access certain routes. Where should this token be stored from the client's end? Such that once given the access token it can be used to access his/her resources?

Thanks

Sep
26
1 month ago
Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

@sti3bas But why is it appearing in my $devices[0] element when I am operating on the $var variable? @nakov I will use that thank you. As far as I know I did not use the $with property

Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

@nakov Thank you for the heads up! Should I put it in a try catch perhaps?

Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

@sti3bas Understood thank you! Now I am trying to get the inverse relationship as follows:

public function show(Request $Request)
    {
        $tagName = request('tagName');
        $devices = Tag::where('name', $tagName)->first()->devices;
        $var = $devices[0];

        return response()->json([
            'tagName' => $tagName,
            'device' => $devices,
            'tag' => $var->tag
        ], 200);
    }

The tag is being returned, however it also getting appended to the $devices[0] variable:

{
    "tagName": "A4 Test",
    "device": [
        {
            "id": 1,
            "device": "2E81FA",
            "latitude": null,
            "longitude": null,
            "tag_id": "1",
            "created_at": null,
            "updated_at": null,
            "tag": {
                "id": 1,
                "name": "A4 Test",
                "description": null,
                "created_at": null,
                "updated_at": null
            }
        },
        {
            "id": 2,
            "device": "2E80CB",
            "latitude": null,
            "longitude": null,
            "tag_id": "1",
            "created_at": null,
            "updated_at": null
        }
    ],
    "tag": {
        "id": 1,
        "name": "A4 Test",
        "description": null,
        "created_at": null,
        "updated_at": null
    }
}
Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

Yeah, that worked! Thanks :) I think it's because the ::where property returns an array of objects and so you need to fetch the first object first?

Activity icon

Started a new Conversation Property [ ] Does Not Exist On This Collection Instance

Tag Model:

class Tag extends Model
{
    public function devices(){
        return $this->hasMany('App\Device');
    }
}

Device Model:

class Device extends Model
{
    public function tag()
    {
        return $this->belongsTo('App\Tag');     
    }
}

In a controller I wrote the following:

public function show(Request $Request)
    {
        $tagName = request('tagName');
        $devices = Tag::where('name', $tagName)->devices->get();
        return response()->json([
            'tagName' => $tagName,
            'device' => $devices
        ], 200);
    }

However I keep getting the following error: Property [devices] does not exist on this collection instance

I expected a list of devices to be returned whose tag_id corresponds to the id of the $tagName.

Aug
29
2 months ago
Activity icon

Replied to Scheduler/Event Listener

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

Activity icon

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?

Aug
13
2 months ago
Activity icon

Replied to 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!

Activity icon

Replied to 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.

Activity icon

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!

Aug
07
3 months ago
Activity icon

Replied to Request Cookie

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

Aug
06
3 months ago
Activity icon

Replied to 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...

Activity icon

Replied to 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...

Activity icon

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?

Aug
02
3 months ago
Activity icon

Replied to 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

Activity icon

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?

Activity icon

Replied to 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?

Jul
22
3 months ago
Activity icon

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!!

Jul
19
3 months ago
Activity icon

Replied to Swift_TransportException When Sending E-mail

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

Activity icon

Replied to Swift_TransportException When Sending E-mail

Turns out I exceeded the daily limit on Sendgrid.

Activity icon

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!

Jul
16
3 months ago
Activity icon

Replied to 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

Jul
15
3 months ago
Activity icon

Replied to 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?

Activity icon

Replied to Call Controller Function From Another Controller

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

Activity icon

Replied to Call Controller Function From Another Controller

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

Activity icon

Replied to 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?

Activity icon

Replied to 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.

Activity icon

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.

Jul
12
4 months ago
Activity icon

Replied to 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.

Activity icon

Replied to Laravel Min Validation Not Working

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

Activity icon

Replied to 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

Activity icon

Replied to Laravel Min Validation Not Working

Will try that thanks!

Activity icon

Replied to 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

Activity icon

Replied to Laravel Min Validation Not Working

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

Activity icon

Replied to 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)

Activity icon

Replied to 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());
            }            
        }
}