Member Since 5 Years Ago

Experience Points

4,235 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
Best Reply Awards
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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 20
95,765 XP
04 Jul
2 months ago

DirkZz left a reply on RFID In Laravel

Depends on what your project is. What do plan to build?

03 Jul
2 months ago

DirkZz left a reply on RFID In Laravel

Ive looked in to this once trying to find out if it was a viable option to do stock monitoring in a warehouse.

I think you should take a look at the product offerings of Zebra. They sell printers and scanners plus they can offer you an SDK. Take note that you probably won't tackle this feature by using PHP/Laravel alone you will need an app that runs on a certified device capable of reading the RFIDs and thats why I would recommend buying all that from 1 single brand like Zebra. (Even if you somehow manage to do it in PHP the real question is if you should .. )

Bear in mind that the scanner might go places without an active internet connection and while scanning it could scan hundreds of items at the same time. With the Zebra SDK you can develop the app as you wish and communicate with your web application in the background thus forwarding the requests/scanned items and manage this process as you wish.

If you have any questions please let me know. I had to research and report on this in depth a couple of months ago. However we decided not to go through with it so I didn't actually get to implement it. (bummer :( seemed like an amazing project.)

28 Jun
2 months ago

DirkZz left a reply on Multiply Product Qty With Rate With Maximum Rate In The List In Relationship

I think the overall idea is a bit flawed here, what should happen when you have purchased 25kg for 1$ and after that you made a bigger purchase of 50kg for $0.8 and a customer comes along and purchases 55kg of that product?

Then you would sell him 25kg for $1 and 30kg for $0.8 based on the cost price totaling $49 making it $0.89 per kg. Just taking the maximum price would give you $55 a huge (unacceptable) difference in my opinion if this is going to be used for a real product in production.

But to answer your question;

If you would really like to do this by using the models then I can write that out for you, but personally I always tuck away queries for reports in their own classes making it easier to work with as the reports stack up, plus I make sure I don't dirty my models with possible reporting stuff and on top of that its usually much faster.

As an example;


namespace App\Queries\Reporting\Sales;

use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

class TotalsOverCustomPeriod
    public static function query(Carbon $from, Carbon $till)
        return DB::table('sales')
            ->join('products', 'products.id', '=', 'sales.product_id')
            ->join('purchases', 'purchases.product_id', '=','products.id')
            ->whereBetween('sales.sold_date', [$from, $till])
                DB::raw('SUM(sales.quantity) AS total_quantity_sold'),
                DB::raw('MAX(purchases.price) AS highest_purchase_price'),
                DB::raw('SUM(sales.quantity)*MAX(purchases.price) AS total_price'),

And use it like so;

$from = (new \Carbon\Carbon)->subWeek(1);
$till = new \Carbon\Carbon();
$report = \App\Queries\Reporting\Sales\TotalsOverCustomPeriod::query($from, $till)->get();
26 Mar
5 months ago

DirkZz left a reply on Mysql Index Key Not Provided When Not Limiting Query Result

Could you put EXPLAIN in front of the query and share the results? Also the table structure might be usefull. Also you mentioned that the table has millions of records, how many exactly and how much rows will this query return?

08 Mar
6 months ago

DirkZz left a reply on What Graps Package Is Good For Laravel And Vuejs ?

Just a link drop but I really like Apexcharts;


07 Feb
7 months ago

DirkZz left a reply on Restricting Access To Laravel Site With Username And Password

@KONRMS - @konrms The error you posted shows a typo; "middlware" instead of "middleware"

08 Oct
11 months ago

DirkZz left a reply on How To Sum The Total Discount Through Many Things

Maybe not the answer which you are looking for, but there is nothing wrong with "normal sql". For these kind of queries I often fall back to the query builder or raw SQL in a DB::select() statement.

I mostly put them in their own specific classes tho, and then I just unit test the query.

e.g. CategoryDiscountQuery, TypeDiscountQuery and place them in an easy to find and recognize namespace. And return it from the applicable model.

I prefer a clear query over garbled up ORM stuff just for the sake of using the ORM any day.

06 Oct
11 months ago

DirkZz left a reply on Laravel 5.4 POST Method Stop Working When Cloning Site To Development Server

@jlrdw I agree with most of what you are saying but this part:

And ENV shouldn't even be used in production rather config information hard-coded.

The "problem" with that is that config files are most likely in git. Or you have to upload the config files manually and add it to .gitignore by default.

They could block the .env by default in the .htaccess but then you are kind of condoning Laravel being installed improperly.

DirkZz left a reply on Laravel 5.4 POST Method Stop Working When Cloning Site To Development Server

This probably caused the issue ( to your initial question);


It didnt match your domain.

DirkZz left a reply on Laravel 5.4 POST Method Stop Working When Cloning Site To Development Server

Everyone was able to watch your .env file at and thus your database credentials, mail credentials etc.

Change these immediatly because they have been compromised.

Its not a good practice to have anything but the /public folder open to the world.

DirkZz left a reply on Laravel 5.4 POST Method Stop Working When Cloning Site To Development Server

Please take this offline now, your test server is insecure. I will tell you why after you take it offline.

DirkZz started a new conversation Laravel Passport Userspecific Scopes.

So today I started digging into Laravel Passport and so far so good, but for my use case I want a 3rd party developer to create an account and after that he/she can create Peronal Access Token with specific scopes.

I can imagine that it is usefull for a developer to create a read only token to use in one place, and a place orders or delete items token in another place. However we as the owner/1st party have specific scopes as well that may only be assigned to us and no other developer may every get permission for these scopes.

So I went and created a scopes and a scopes_users table defining which scopes should be visible at all to a specific user, so far so good.

But the documentation specifies that the following should go in the AuthServiceProvider

    'list-brands' => 'List all brands',
    'delete-orders-of-other-users' => 'Delete orders of others',

But in the AuthServiceProvider I have no authenticated user ofcourse, what would be an appropriate place to put the following;


I have placed in the routes file as a quick test, and it works, but ofcourse it doesn't belong there.

With this code when a users requests his scopes which he may or may not set when creating a Personal Access Token it will be limited to the scopes that we as the 1st party have allowed in the first place. And this an approach like this even ok? Or will I get in trouble with this approach?

Or I could just override the default tokensCan method and create my own database implementation?

I am a Laravel Passport virgin so I am curious if anyone has ever been in the same situation and some tips regarding my usecase would be very helpfull and appreciated!

04 Oct
11 months ago

DirkZz left a reply on When Others Login To My Site, Everyone Is Getting Last Logged In Users Auth

@asamamun The only way I can reproduce your situation in a project of my own is when I copy the contents of another session file ( located in /store/framework/sessions/ ) to my own active session file.

Maybe you can look in that direction?

DirkZz started a new conversation Laracasts: Notify A User That He Is About To Respond To An Old Discussion.

I think that sometimes users find their way to Laracasts and start replying to discussions without realizing that the last reply to that discussion was years ago.

Is it an idea to notify users about this so they can make the discussion wether or not the answer will still be relevant? So old discussions aren't bumped for no reason.



DirkZz left a reply on DELETE RECORD

Adding to @Cronix answer.

You can also put this logic in to an observer https://laravel.com/docs/5.7/eloquent#observers

Or on the Client model:

    public static function boot()

        static::deleting(function ($user) {
            // More queries but triggers possible events on the ticket model .
            // More efficient query but doesnt trigger events on the ticket model.

With this code if you call Client::first()->delete(); Then it will delete the tickets first followed by the client.

However, if the desired behaviour is that you cannot delete a Client that has tickets, you can check it by count the relation and act accordingly or catching the error in a try catch.

Also with the code stated above you can throw a custom exception when the client has tickets.

DirkZz left a reply on When Others Login To My Site, Everyone Is Getting Last Logged In Users Auth

I can reproduce this error like so;

Login on FireFox (Test1): f1984095@nwytg.net testtest

Login on Chrome (Test2): wkl11047@awsoo.com testtest

Then I refresh FireFox a couple of times, followed by a couple of refreshes in Chrome and then FireFox again.

After a few seconds on Firefox I am also logged in as Test2.

This isn't default laravel behaviour and without code I can't really tell what is wrong.. But I would really re-check the login stuff..

Both the code as the session files that get written depeding on which session driver you use.

But also check for stupid gotcha's like someone using methods like Auth::logingUsingId($SomeWeirdValueThatIsLastLoggedInUser);

My answer is quite vague, but so is your problem description.

DirkZz left a reply on GDPR For Developers

At the first point I am already a bit lost, the forget me part. He is talking about deleting users and nulling all foreign keys on an order table for example.

But what I have been told by a (Dutch) lawyer "specialized" in this ( as far as anyone can call him or herself specialized on something as vague as the GDRP in these early stages ). Is that making a user not recognizable as an individual reallife identity/person is enough.

So renaming all "deleted" to John Doe, assigning "Acme" addresses is enough and at that point you can leave the database ID intact.

A bonus is that your access log to that john doe is still intact as well.

That goes for enumerating numbers (PK auto increment), would still mean that one is pretty fucked when you only use natural keys everywhere on columns like SSN's like they teach you on university.

As far as data retention goes, you can still keep data for a loong while as long as you have stated it in your terms and have probable reasons for it. E.g. in ecommerce customers have a warranty period but that can be limited to the customer (person) that made the purchase.

So anonymizing data is only needed on records that have no active use what so ever anymore to use cases that are needed to satisfy any rights a user may have as defined in the laws of a country. (tax, warranties etc)

What do you guys think about this or what have you heard? Am I completely wrong? I am curious to learn more or to be corrected if my information is completely off.

11 Jul
1 year ago

DirkZz left a reply on Desperate For Ideas On Possible Design Patterns

Yea I know that feeling ;), the pricing needs a comma somewhere.

Just to get back on topic then;

Most of the times I just press F12 first to see if the website is using an "private" api themselves.

If they don't I usually fall back to using simplehtmldom the code isnt very pretty to look at but it has served me well for many years now. http://simplehtmldom.sourceforge.net/ Or guzzle as mentioned before.

DirkZz left a reply on Desperate For Ideas On Possible Design Patterns

I dont know if you have a budget for this and how critical it is to you but it might be worth to take a look at https://www.diffbot.com. You can feed it urls and query them as an api.

As an example a product page on amazon becomes this; https://pastebin.com/wMwfTK4d

When I wanted to use it the pricing was the only thing that put me off ( very expensive imo) but that might not be the case for you.

10 Jul
1 year ago

DirkZz left a reply on 3 Roles Inside One Project Vs 1 Projects For Each Role

( disclaimer; just an opion based on projects I work on, might be completely irrelevant to people working on different projects with different requirements, and I tend to change opinions over time :D Kind of hoping other people firmly object to this with some good constructive criticism.)

In your given example you will still have a lot of overlap in functionality, personally i'd keep everything the same codebase. Because on both sides you are still working a lot with generic stuff like; categories, brands, products.

And even somewhat more advanced stuff has a lot of overlap altho it being with a different label. What a customer considers to be an order a seller will consider it to be a sale.

Yes an order might have different functionality to a sale it also has a lot in common for example displaying the products sold or showing ordervalues.

It is possible to workaround those issues by extracting it to packages and some might even prefer that.

But to use models as an example i'd much rather have a default Order model with generic stuff and have a CustomerOrder and a SalesOrder both extending that Order with functionality specific to the context in there.

Or namespacing them, like I would with controllers and in my routes.

29 May
1 year ago

DirkZz left a reply on Eloquent Standalone, Unable To Query With Count And GroupBy

Your future you or fellow programmers working on the project will thank you if you get rid of the global now.

Bobby was right but you had this error; Fatal error: Uncaught Error: Class 'DB' not found because you didnt reference it by the full namespace, or including it at the top with the use statement.

If you use PHPStorm you can let it autocomplete it for you with Alt + Enter.

DirkZz left a reply on Guidance For Implementing Search Query

Using the query builder you won't get a user relation like you are using in your blade file. You are basicly by passing all the models you made. Besides that in the select statement specifically request the grades data only.

You can start by testing the following;

$grades = Grade::with('users' )->get();

And then go from there. You can also add users.* to your select statement and get the data like that.

Personally if i were you i'd try both options and notice the differences for yourself a nice and fun training exercise ;)

26 May
1 year ago

DirkZz left a reply on Get Latest Record By Day!

This will probably give you what you are after then;


DirkZz left a reply on Get Latest Record By Day!

@Jelly The query I posted should work then.

25 May
1 year ago

DirkZz left a reply on Get Latest Record By Day!


Used a subquery to get the highest SM_ID for each group of STO_ID and then selection the rest of the information using where in.

Does this yield the result you are after? (replace "table" with the table name. ) As I was a bit confused you wanted it "per day" but your expected output has the same date multiple times. So I assume STO_ID is the day of the week.

If anyone has a better performing solution then I am interested as well.

20 May
1 year ago

DirkZz left a reply on How To Run Codeigniter Project Inside A Laravel Project

I'd put domain.com/design under design.domain.com if possible. Otherwise i'd have 2 folders before the /public or /public_html folder and symlink them.

02 Apr
1 year ago

DirkZz left a reply on So Many Bad Sites In The Wild

For a lot of companies programming doesn't have any focus at all. Nothing new.

Maybe the GDRP will change it a bit, altho its vague as f.. at least it makes security a discussion worth having.

01 Aug
2 years ago

DirkZz left a reply on Updating (Upserting) Thousands Of Mysql Records Freezes Regularly

You could go plain SQL if your database throws an error when you try to insert a row which already exists or breaks an unique constraint. You can also batch up your inserts at that point.

For example:

INSERT INTO table(a,b,c) VALUES (1,2,3),(3,4,5),(6,7,8)

In this example it will try to insert all rows, if it finds a conflict with your PK or any other unique constraint then it will trigger the "On duplicate key" part. In this example it will; leave colum "a" as is and update colums B and C with the new values.

If this is new; try it in development first. And I wouldn't do a batch insert with 280K rows you still need to chunk it up.

The maximum rows you can insert/update at once are determined by the mysql variables; max_allowed_packet, bulk_insert_buffer_size, key_buffer_size.

So it depends on your data and config if you can insert/update 100 at a time or 10.000 at a time.

28 Jun
2 years ago

DirkZz left a reply on Can I Use Laravel 5.5 Now ?

I'd go for 5.4 personally and just follow the upgrade guide when 5.5 is officially released. Some refactoring might be required if you wish to use some of its new functionality but at least you have documentation to fall back on at that point.

22 Apr
2 years ago
19 Apr
2 years ago

DirkZz left a reply on [Laravel 5.4 Coventions] - Where Should I Create Functions

If you follow JoerJoers advice then you can completely skip this answer because indeed a select box would be the preferred method.

However if the lookup by a name which the user typed is desired behaviour, some feedback and to get some insight in some awesome laravel functionality;

You are iterating over a collection you get by looking up the name you received and assigning each value to $id which could give you weird behaviour if multiple locations have the same name because $id will always hold the last value in the collection. Also "->pluck()" returns a collection so you could also replace the foreach loop by appending " ->last()" to "->pluck()" for the same behaviour.

If the name field indeed has a unique constraint on it at the database level then you could skip the iterating over it all together by just replacing pluck with "->first()" at that point you can simply fetch the location_id by using "$idLocation->id_location"

Lots of awesome stuff is already built in to make your code cleaner if you want to you can read all about it here:

https://laravel.com/docs/5.4/collections https://laravel.com/docs/5.4/eloquent-collections

You could even strip the validation out to a form request https://laravel.com/docs/5.4/validation#form-request-validation

All of this is absolutely not mandatory but perhaps it gives you some extra insights.

18 Feb
2 years ago

DirkZz left a reply on Hacked

@Zurik.Ludg that is correct, and if for some reason it isnt possible to change the root to "/public" you can also create a symlink from "/public_html" to "/public".

When that isn't possible either then I personally would find another host, but as a last resort you can also deny access to all sensitive files in the .htaccess file.

DirkZz left a reply on Hacked

@Snapey Good idea, it will look silly to the majority of people but there is also a huge group out there that would benefit from this.

DirkZz left a reply on Hacked

Holy fuck why would you make your .env file publicly available, i just tried a search on google for the filetype .env and people are doing this by the massess.

@JeffreyWay perhaps its an idea to make a video about security and explain a few no-no's like this?

15 Feb
2 years ago

DirkZz left a reply on Did I Lose My Search Privilege?

I think an update went wrong, multiple things are broken it seems. Theres a blank menu item, the catalog is empty, search is gone.

05 Jan
2 years ago

DirkZz left a reply on Algolia Search By Category ID

I think that what you are referring to is to set fields that are actually searchable when a user is querying for something. If you want to filter the set with specific parameters then this is what you are probably looking for:


17 Dec
2 years ago

DirkZz left a reply on NoSQL In Laravel

@Presto Lets agree to disagree :)

16 Dec
2 years ago

DirkZz left a reply on NoSQL In Laravel

@Presto I have a hard time finding a use case for MySQL over MongoDB. I personally believe that developers who try and argue the point may not have ever used MongoDB in a live project before.

I just really like data integrity,consistency most of the times, so please don't preach for mongodb out of the box. It certainly has its (very) specific usecases but I think you are overstating its purpose a bit with this statement.

13 Dec
2 years ago

DirkZz left a reply on What Are You Working On ?

Nice topic! Always interesting to see what other people are working on and what they are using/doing to accomplish that.

Currently building a rest api which basically talks with an external soap api for creating shipping labels for parcels we send out. After that we will consume that api using Vue and send the labels directly to a connected printer over usb.

12 Dec
2 years ago

DirkZz left a reply on Creating HTML Driven PDFs With L 5.3

I use https://github.com/barryvdh/laravel-dompdf

Just be carefull with large tables that span multiple pages, it pushes the processor to 100%

DirkZz left a reply on Freelancer Paid By Country - Is It Fair?

I agree with @willvincent maybe the difference isnt as big as comparing countries to each other but here in the Netherlands wages in Amsterdam for example are higher then inlands as well not only because companies located in Amsterdam tend to be bigger but the simple fact that housing is more expensive etc contributes to that as well.

Simple case of offer and demand.

09 Dec
2 years ago

DirkZz left a reply on Is It Just Me?

Well its personal, but the pace is a big plus for me. I tend to drift away when I watch someone typing at turtle speed. For me it is perfect as is.

DirkZz left a reply on Update "updated_at" Each Time A User Logged Into


'Illuminate\Auth\Events\Login' => [

add this to your EventServiceProvider run php artisan events:generate and do your magic in the created LogSuccessfullLogin listener.

06 Dec
2 years ago

DirkZz left a reply on Strange View (blade) Problem

Check the outputted source in you browser and look for anything familliar near the 's' to give you a starting point of where to look. Or perhaps you can just cutout pieces of your template at a time and check when the 's' dissapears?

04 Dec
2 years ago

DirkZz left a reply on Laravel 5.3 And Vue.js 2.0 Gulp

It is 3MB because of all the development stuff. Try running gulp --production and check the size again ;)

03 Dec
2 years ago

DirkZz left a reply on How To Count User Logins?

Overriding the default isn't necessary for this usecase, you can listen for the events mentioned here.


24 Nov
2 years ago
03 Nov
2 years ago

DirkZz left a reply on Simplify This

Call a named route?


$router->get('register/{slug}/verify/{code}',  ['as' => 'verifyRegistration', 'uses' => '[email protected]']);

route('verifyRegistration', [$user->slug,$user->confirmation_code])
18 Oct
2 years ago

DirkZz left a reply on Json In Database Over EAV Model In Products Table

Since it is the third time you asked and you are probably Dutch, maybe you can post this question on tweakers as well. You'll probably get an answer from the moderator explaining how they did it with their millions of products.

As to your challange, its quite a difficult one and I am not really sure how to answer this. What are attributes exactly in this context is it the mapping of properties on a product which the client can adjust or are we actually talking about products which have multiple colors, different sizes etc?

In your other topic you pointed out that one of your issues was exporting it every 15 minutes because the stock is constantly updating you probably won't sell 50k products each 15 minutes so perphaps you can get away by "caching" the file somewhere and only updating the handfull of fields that actually changed, that would atleast save you the time to look everything up again.

12 Oct
2 years ago

DirkZz left a reply on Time Zone Europe/Amsterdam

Is the system time of the server correct?