Chris1981

Chris1981

Member Since 3 Years Ago

Experience Points
16,370
Total
Experience

3,630 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
129
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 4
16,370 XP
Sep
14
3 months ago
Activity icon

Started a new Conversation Update Last Login When Requesting Oauth/token

Hey,

When I go to log in a user on my API using /oauth/token, I want to also update the user table with some login details, i.e

$user->update([
    'last_login_at' => Carbon::now()->toDateTimeString(),
    'last_login_ip' => $request->getClientIp()
]);

Is there any easy way of doing this?

Sep
09
3 months ago
Activity icon

Started a new Conversation Laravel Passport Mentor

Hey Guys,

Im looking for a mentor, someone that has a lot of knowledge with building API's with Laravel Passport.

I've got so many questions, and I would rather 'hire' someone to help me answer instead of flooding forums with questions that might sound daft to other people.

Any help would be greatly appreciated :)

Thanks in advance

Sep
08
3 months ago
Activity icon

Started a new Conversation Having Some Issues With Laravel Passport And Best Practices

Hey Guys,

I was wondering if I could get a little bit of code mentoring for a few issues im seeing. I have created a pure API instance of Laravel + Passport on api.domain.com and im consuming in a pure React instance on www.anotherdomain.com so they are completely different entities.

The issues im having are around authentication and the best / most secure ways of doing it. I have read quite a lot of tutorials and each one is quite different as to how they do it.

My currently login method in Laravel loooks like this;

public function login(Request $request)
{
    $request->validate([
        'email' => 'required|string|email',
        'password' => 'required|string'
    ]);

    $credentials = request(['email', 'password']);

    if(!Auth::attempt($credentials)) {
        return $this->sendError('Unauthorized', '', 401);
    }

    $user = $request->user();

    $tokenResult = $user->createToken('Personal Access Token');
    $token = $tokenResult->token;
    $token->save();

    $data['access_token'] = $tokenResult->accessToken;
    $data['token_type'] = 'Bearer';
    $data['expires_at'] = Carbon::parse($tokenResult->token->expires_at)->toDateTimeString();

    return $this->sendResponse($data, 'User logged in successfully.');
}

This works fine, but is this the best way of doing it as I see some tutorials get a refresh token as well, but im not sure what that does. Also the expires_at is never used on the frontend.

On the frontend my login method is simple;

return axios.post(baseUrl + 'login', formData, {
    headers: {
        Accept: 'application/json'
    }
})
    .then(response => {
        const token = response.data.data.access_token;
        localStorage.setItem('access_token', token);

        return response;
    })
    .catch(error => {
        return error;
    })

This seems not to be all that secure storing the access_token in local storage .... Whats the best way of storing this?

Also, I was watching a tutorial with VUE and to protect a route, they simply used a conditional to check if the access_token was not null .... But this seems a bit ugly, what happens if that token had expired.

Sorry for the load of questions, but I can't seem to find a place to read that seems ......... good practice.

I dont want to put an app out into the public with terrible authentication.

Thanks in advance.

Sep
05
3 months ago
Activity icon

Started a new Conversation React Authentication Using Laravel Passport

Hey guys,

I was wondering if anyone knew of a resource to learn how to use Laravel Passport authentication in a React app.

I can't find anything anywhere.

Thanks in advance.

Sep
04
3 months ago
Activity icon

Started a new Conversation Password Reset API Being Consumed From Different Frontend Urls

Hey Guys,

I am following a tutorial found here https://medium.com/modulr/api-rest-with-laravel-5-6-passport-authentication-reset-password-part-4-50d27455dcca for developing an API.

Im wondering how it would be possible to consume this from different frontend URL's given that the password reset link in the email points to one domain.

Is it possible to send something that gives the email function a dynamic link to access?

I hope that makes sense.

Jun
22
5 months ago
Activity icon

Started a new Conversation Retrieving Information From 3 Tables

I'm trying to get information from 3 tables in Laravel 5.8 but so far i have just come up with nothing.

The 3 tables look something similar to the following;

polls
    id - integer
    name - string
    status - tinyint

poll_options
    id - integer
    poll_id - integer
    image_id - integer
    status - tinyint

poll_images
    id - integer
    filename - varchar

A poll has several poll options, those poll options have 1 images each.

I would like to get poll options with the poll status of 1 and any images that have poll options with a status of 1

I need the get the filename, the poll option id and the poll id.

I'm so confused

Any help would be greatly appreciated.

Jun
17
5 months ago
Activity icon

Replied to Converting MySQL To Laravel Migration

@aurawindsurfing .. Thanks, I will check it out. Cheers,

Activity icon

Replied to Converting MySQL To Laravel Migration

Hey @aurawindsurfing ... Thats what im having trouble with, is writing the bottom bits by hand.

This is what I have so far

$table->bigIncrements('id');
$table->bigIncrements('poll_id');
$table->string('name', 255);
$table->tinyInteger('status')->nullable(false)->default(1);
$table->timestamps();

But the rest i dont know how to do

Activity icon

Started a new Conversation Converting MySQL To Laravel Migration

Hey Hey,

Im in the process of creating some migrations for a sample thing im writing, i have the original SQL table structure but im having a little trouble when it comes to the primary key, key, and constraint at the bottom.

I would really appreciate some help. The SQL is as follows;

CREATE TABLE `poll_options` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `poll_id` int(11) NOT NULL,
 `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `created` datetime NOT NULL,
 `modified` datetime NOT NULL,
 `status` enum('1','0') COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
 PRIMARY KEY (`id`),
 KEY `poll_id` (`poll_id`),
 CONSTRAINT `poll_options_ibfk_1` FOREIGN KEY (`poll_id`) REFERENCES `polls` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;