neilstee

neilstee

Member Since 2 Years Ago

Experience Points
22,210
Total
Experience

2,790 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
174
Lessons
Completed
Best Reply Awards
4
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 5
22,210 XP
Oct
30
7 hours ago
Activity icon

Replied to Laravel Showing Json While Storing Data

@rafidahsan your conditions in store() function has return $request;. Looks like one of them is getting triggered.

Oct
21
1 week ago
Activity icon

Replied to Performance Issues Advice

@mick79 have you tried analyzing the query using EXPLAIN?

explain select * from users where email like "%gmail.com%";

See if you get the same results in staging and prod

Activity icon

Replied to Is My Socialite Facebook Avatar Code About To Break?

@kensmithzzz based on the upcoming changes, you just need to include a user token in your URL.

You can read more about this here: https://developers.facebook.com/docs/graph-api/reference/user/picture

Oct
14
2 weeks ago
Activity icon

Awarded Best Reply on Preload Function

@kikoldasd you need to make two

<link rel="preload" href="style.css" as="style">
<link rel="stylesheet" href="style.css">
Activity icon

Replied to Preload Function

@kikoldasd you need to make two

<link rel="preload" href="style.css" as="style">
<link rel="stylesheet" href="style.css">
Activity icon

Replied to Laravel Passport Access Tokens Timezone

@bobbybouwmann for sure man! thanks for the help!

Oct
13
2 weeks ago
Activity icon

Replied to Laravel Passport Access Tokens Timezone

@bobbybouwmann we updated the DateTime on servers and it works!

Oct
06
3 weeks ago
Activity icon

Replied to Laravel Passport Access Tokens Timezone

@bobbybouwmann sadly, I can't do the datetime update now but only on weekends because it's a production server. So I can't test if the server time difference is causing the problem.

Another thing I found is the token itself has an expiration date and issued at date after I decoded it using https://oauth.tools/ <- not sure if legit tho

iat 1601965485 // issued at
nbf 1601965485
exp 1603261485 // expiry

so iat seems to play a big role here because the server1 that generates the token is 10mins ahead on the server2. then if the server2 access those token, it will say "Unauthorized" but will be authorized after 10mins (which I believe the iat takes effect).

I can't find an article if the checking of token includes iat because I thought it was only the exp that matters.

Activity icon

Replied to Laravel Passport Access Tokens Timezone

lol I thought I'm getting more answers after I woke up 😅

Activity icon

Replied to How To Use Xampp Php Instead Of Built-in Php?

@david001 you can manually run the exact path on your terminal or alias it (add to your system path), I believe you are in Windows?

So instead of php artisan serve, make it C:\xampp\php\php.exe artisan serve.

Please locate your php.exe yourself because my path might be wrong.

Activity icon

Replied to Laravel Passport Access Tokens Timezone

@bobbybouwmann thanks for the suggestion.

As I said in my post, there is a 10mins difference in time on both servers.

I just want to confirm here if that really affects the token or the time difference on the servers and the time that the token suddenly works is just a coincidence.

I'll try to update the time on the servers and see if that fixed it.

I have the same issue here as well: https://laravel.io/forum/laravelpassport-multi-server-issues

Thanks!

Activity icon

Started a new Conversation Laravel Passport Access Tokens Timezone

I have 2 WebApps in which connects to one MYSQLDB.

  1. WebApp1 creates access token after a user is login and save it to MYSQLDB.
  2. WebApp1 then request a GET request to WebApp2 with auth token.
  3. WebApp2 then check those oauth token from MYSQLDB and verify if it's legit.

The problem is WebApp2 says "Unauthorized" although the token is correct.

But weirdly enough, after 10mins it will work.

Then after checking my WebApp1 and WebApp2, they have 10mins difference in time.

My question is, does time difference affects how oauth works?

Thanks!

Oct
02
4 weeks ago
Activity icon

Replied to How To Sort Two Array Value From Lowest To Highest And Retrive

@michaloravec wow! I like your approach better using Collections.

@saurav77 I prefer @michaloravec answer than mine because mine is pure PHP than Laravel.

Activity icon

Replied to How To Sort Two Array Value From Lowest To Highest And Retrive

@saurav77 you can combine them first like:

$data = array_combine($users, $bidder);

asort($data); // then sort by value 

so now you can loop through $data and use users_id as key and bidder as value

Activity icon

Replied to How To Sort Two Array Value From Lowest To Highest And Retrive

@saurav77 users array corresponds to bidder array? but they are both separate data correct?

Activity icon

Replied to I Want To Display All Users Who Send Messages To Auth User

@mikeli

I think you misplaced the WHERE clause, it should be after the ON users.id = messages.from.

Also, you might want to check if is_read = 0 AND conversation = 1 is correct, if this is correct then it should be something like:

$users = DB::select("select users.id, users.firstname, users.avatar, users.email, count(is_read) as unread from users LEFT JOIN messages ON users.id = messages.from WHERE is_read = 0 AND conversation = 1 AND messages.to = " . Auth::id() . " AND users.id != " . Auth::id() . "

Activity icon

Awarded Best Reply on Conditional Image Upload

@app_dev

$this->validate($request, [
             'image' => 'dimensions:width= 1920,height=1080'
        ]);

source: https://laravel.com/docs/8.x/validation#rule-dimensions

Activity icon

Replied to How To Check Exist Data In Relationship Table And Redirect If Data Exist

@balamurugan08 I might misunderstand your question but what you want to achieve is to redirect the user from "home" to "addvoucher" page when a certain condition is met (in this case, if the user already registered their company details).

I assumed you have a Controller for your "home" route. And I assumed your User hasOne CompanyDetails relationship (I hope you share your code for clarification)

HomeController.php

public function home()
{
	if (auth()->user()->companyDetails()->exists()){
		return redirect('addvoucher');
	}

	return view('home'); // if false then register their company details
}

User.php your Model

public function companyDetails()
{
	return $this->hasOne(CompanyDetails::class);
}

This is, of course, assuming you use this kind of data (since you didn't share any code) and error might show up but you should get the idea.

Activity icon

Replied to Conditional Image Upload

@app_dev

$this->validate($request, [
             'image' => 'dimensions:width= 1920,height=1080'
        ]);

source: https://laravel.com/docs/8.x/validation#rule-dimensions

Oct
01
4 weeks ago
Activity icon

Replied to The Goodbye Debacle - PODCAST

After hearing Jeffrey's explanation in the podcast, I feel sorry for him that people take it seriously and rude.

But before that, I was annoyed too especially the phrase "We'll have you replaced in 5 seconds". Feels like I'm not important given I paid for a subscription in the past x months.

Anyways, too many negative things happened this year so why add this up :)

Sep
29
1 month ago
Activity icon

Replied to How To Get The Validation Message In Laravel Inside Modal?

how about dd($errors) in view?

Activity icon

Replied to How To Get The Validation Message In Laravel Inside Modal?

can you dd($this->username()) ?

Activity icon

Replied to Laravel Logout

@dembilesmana because it's in the menu structure that uses anchor tags.

So it looks simpler than nesting all the form and button in the menu.

Activity icon

Replied to How To Get The Validation Message In Laravel Inside Modal?

@imrulhasan273 can you share the validation on the controller?

Activity icon

Replied to How To Get The Validation Message In Laravel Inside Modal?

@imrulhasan273

@error('user_name')
        <div style="color:white" class="alert alert-danger">{{ $message }}</div>
@enderror

or

@error('password')
        <div style="color:white" class="alert alert-danger">{{ $message }}</div>
@enderror
Activity icon

Replied to Get Current User's Role

@divyaguru do you have role column on your User? If so you can do this:

public function hasRole($role)
{
    return User::where('role', $role)->get();
}
Activity icon

Replied to "Best Answer" Follow Up Notification?

@jlrdw thanks for sharing your thoughts!

The "Best Answer" though is very subjective in particular to the question and this happens a lot in StackOverflow questions where the 2nd answer is sometimes the "best" answer in line with the standards, security, etc.

But maybe to your point, it's a good idea to have a downvote feature to an answer?

Activity icon

Replied to Laravel Logout

@dembilesmana because of the @csrf directive.

You can checkout this video: https://laracasts.com/series/laravel-6-from-scratch/episodes/37

Activity icon

Replied to "Best Answer" Follow Up Notification?

@sinnbeck maybe the impact is not that big then. Thanks!

Activity icon

Replied to Cancel Event Of Swal Button

@yashika on your 2nd parameter you can add a callback function:

swal({/*your config here*/}, function(value){
        if(value===false){
     		window.location.reload();
	}
});

or if that doesn't work you can use .then

swal({/*your config here*/})
.then((value) => {
        if(value===false){
     		window.location.reload();
	}
});

Activity icon

Replied to Composer PHP Fatal Error: Allowed Memory Size Of 1610612736 Bytes Exhausted

You can bypass this using COMPOSER_MEMORY_LIMIT=-1:

COMPOSER_MEMORY_LIMIT=-1 composer require vendor/package

Or change in your php.ini memory_limit=-1

Activity icon

Started a new Conversation "Best Answer" Follow Up Notification?

Does Laracasts notify it's users to choose a "Best Answer" in their previous posts if it got replies?

It seems that some questions that got answered correctly are not marked as "Best Answer".

Probably they forgot it so notification could be helpful?

Activity icon

Replied to How To Do An Instagram CURL In Laravel 8?

@obink

@php 
$response = Http::withOptions([
    'debug' => true,
])->get('https://graph.instagram.com/me/media?fields=id,media_url,permalink&access_token=this1st0k3n');

// from here you can decide how you want to print it based on the data you get
dd($response); 
@endphp 
Sep
28
1 month ago
Activity icon

Replied to Need Help Refactoring In Vue

@chrisgrim I think you can clean this up using vue route?

So you can access this parameter like: $route.params.city

Activity icon

Replied to How To Do An Instagram CURL In Laravel 8?

@obink instead of using {{ }} use @php @endphp directive instead:

@php
function fetchData($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
// Pull and parse data.
$result = fetchData("https://graph.instagram.com/me/media?fields=id,media_url,permalink&access_token=this1st0k3n");
$result = json_decode($result, true);
$limit = 6;

@endphp

// then the rest of code goes here...

Activity icon

Replied to Problem Show In Vue Js

@roughlik because you call it $ItemsMdCount in your code.

So you need to change it to $itemsMdCount. smaller "i"

Activity icon

Replied to Alternative To "new Up” Objects In Other Objects

@royksoft as Jeffrey Way always says, it all comes down to experience.

In my experience, I only use the basics of Laravel almost 90% of the time.

The other 10% is when I reach out to those complex stuff.

So don't overthink how to use them, focus on the problem that you are solving, and eventually you will come across a problem in which you need to use those techniques.

Good luck!

Activity icon

Replied to Problem Show In Vue Js

@roughlik you should add ->get() on both queries.


$itemsCount = DB::table('items')
                    ->groupBy('level_id')
                    ->selectRaw('level_id, count(*) as type')
		    ->get();
$ItemsMdCount = DB::table('items')
                        ->groupBy('project_model_id')
                        ->selectRaw('project_model_id, count(*) as type')
                        ->get();
Sep
25
1 month ago
Activity icon

Replied to Alternative To "new Up” Objects In Other Objects

@royksoft you might want to look at Service Containers.

You can check out this series: https://laracasts.com/series/laravel-6-from-scratch/episodes/38

Activity icon

Replied to Style Default Login Screen Login.blade.php

@nikokont I think what you need to look at is the webpack.

We have a series here in Laracasts: https://laracasts.com/series/laravel-6-from-scratch/episodes/17

If you want to go deeper you can check the documentation: https://laravel.com/docs/8.x/mix#sass

Sep
21
1 month ago
Activity icon

Replied to Getting Errors When Running Npm Run Dev

@shiva I think it's best to commit your actual js files instead of generating it on the server.

Activity icon

Replied to Laravel Cache Available In A View

@phread I assume you are caching model and then you update your Controller based on the Cache::class

There is a package where you have this automatically, you just need to add Cachable trait in your Models and everything will work the same except they are cache when available.

Check here: https://github.com/GeneaLabs/laravel-model-caching

Activity icon

Replied to GIT Pushing

@afoysal just checkout on another branch (you still keep the changes) then push your changes to the newly created branch

git checkout -b new-branch
git add .
git commit -m "my changes"
git push origin new-branch
Activity icon

Replied to Laravel 7 Validation Unique Multiple Columns

@hosamalzagh you can use Rule::unique

'exam_class_id' => ['required', 'integer',
    Rule::unique('exam_starts')->where(function ($query) use($request) {
	return $query->where('exam_class_id', $request->exam_class_id)
	   ->where('student_id', $request->student_id);
    }),
],
Activity icon

Replied to How To Set Up Remote Mysql Connection With Ssl

@mspace have your tried clearing cache in artisan?

php artisan config:clear
php artisan config:cache
php artisan cache:clear
Sep
20
1 month ago
Activity icon

Awarded Best Reply on Ajax Update - How To Append A Line Or Or Insert A New Line Without Reload

@singh I assumed you are using jQuery and you want to update the data that you have edited in the table?

Given that you have:

  • row id in your table
  • dataResult that contains id, name, type, rate, default values

I suggest adding classes to your html for example:

<table>
	<tr id="tax-1">
		<td class="tax-name">this is name</td>
		<td class="tax-type">this is type</td>
		<td class="tax-rate">this is rate</td>
		<td class="tax-default">this is default</td>
	</tr>
	<tr id="tax-2">...</tr>
	...
<table>

Then in your JS:

// remove your location.reload(); and add the following
$('#tax-' + dataResult.id + ' .tax-name').text(dataResult.name);
$('#tax-' + dataResult.id + ' .tax-type').text(dataResult.type);
$('#tax-' + dataResult.id + ' .tax-rate').text(dataResult.rate);
$('#tax-' + dataResult.id + ' .tax-default').text(dataResult.default);

There can be an error but you should get the idea.

Sep
19
1 month ago
Activity icon

Commented on Business Logic

Another reason why you may want to wrap the updating of $this->completed property to a function is when you decided to change it.

You said earlier that completed can be a completed_at timestamp in the future. instead of changing all the completed property to completed_at in your codebase, you only need to change it in one place and everything is updated :)

Sep
18
1 month ago
Activity icon

Replied to (SQLSTATE[HY000]: General Error: 1364) , After Adding Another Pivot Column

@obink have you tried in your migration:

$table->integer('orderPrice')->nullable()->unsigned();

or you can do also:

['orderPrice' => $pricing[$product] ?? 0]