DirkZz

DirkZz

Member Since 5 Years Ago

Experience Points 94,935
Experience Level 19

65 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 866
Lessons
Completed
Best Reply Awards 18
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 Mar
2 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
3 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;

https://apexcharts.com/

07 Feb
4 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
8 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
8 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

As far as your original issue goes, did the issues occur after the update to 5.5 or was it still on 5.4?

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 http://45.33.17.138/sm/.env and thus your database credentials, mail credentials etc.

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

Passport::tokensCan([
    'list-brands' => 'Place orders',
    'check-status' => 'Check order status',
]);

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

Passport::tokensCan(
    auth()->user()->scopes->pluck('name','handle')->toArray()
);

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? 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
8 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 is 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.

Example;

Imgur

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){
        $user->tickets->each->delete(); // More queries but triggers possible events on the ticket model.
        $user->tickets()->delete(); // More efficient query but doesnt trigger events on the ticket model.
    }
}

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
11 months ago

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

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

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/c74cF4X4

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
11 months 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.

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;

SELECT * FROM table
WHERE SM_ID IN ( SELECT MAX(SM_ID) FROM table GROUP BY STO_ID, DATE(created_at) ) 

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!

SELECT * FROM table
WHERE SM_ID IN ( SELECT MAX(SM_ID) FROM table GROUP BY STO_ID ) 

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?

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

DirkZz left a reply on Get Latest Record By Day!

SELECT MAX(id),DATE(created_at) FROM table GROUP BY DATE(created_at) HAVING DATE(created_at)=MAX(created_at)

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
1 year ago

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

@diginize

One thing that did surprise me while this big update runs is that neither the php or mysql processes seem particularly stressed on CPU or RAM usage.

Aren't hitting your maximum execution time?

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)
ON DUPLICATE KEY UPDATE  b=VALUES(b),c=VALUES(c)

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
1 year 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.

DirkZz left a reply on Laravel Training

Then you'll probably find use for this as well;

http://cheats.jesse-obrien.ca/

DirkZz left a reply on Laravel Training

@teckel Maybe this is something you'll like https://laravel.com/api/5.4/

26 Jun
1 year ago

DirkZz left a reply on Laravel Training

@teckel

"And I don't even understand what you mean by my custom build framework. As stated, I don't know what a framework is."

Am I correct to say that you copy/paste logic across projects for; Managing queries, for logging in users, easy to use text-formatting functions and tons of other stuff?

That is essentially what a framework is, that is essentially what Laravel does.

How does it do that?

To give an example list (there is much more);

Validating form input https://laravel.com/docs/5.4/validation

Handling sessions https://laravel.com/docs/5.4/session

Handling authentication https://laravel.com/docs/5.4/authentication

Working with sets of data https://laravel.com/docs/5.4/collections

Database queries https://laravel.com/docs/5.4/queries

A long list of other generic helpers https://laravel.com/docs/5.4/helpers

90% of all projects need all of this functionality.

Why would you build and maintain this boring stuff yourself? It is no fun and it adds no value to the company at all. I'd much rather write business logic.

I do understand that you might get frustrated with all these different and new things being thrown at you at once.Again this is not a personal attack; But I think it also comes down to your attitude towards the changes being made within the company. Because there is no reason why you aren't able to google "Framework".

A genuine advice; Sleep on it for a day, realize that it isn't the entire world that has gone crazy but that there is a possibility that all these newly invented workflows making use of composer for example have huge benefits.

And when it comes to learning all this; Laracasts is a good source but as you pointed out it isn't for you. Ask co-workers to help you, or look for a hands on class in your neighbourhood.

Shouting here is a waste of time because yes some understanding of concepts are important to understand why things work how they work, and no one in this forum can explain them all to you in a single reply. It requires someone looking over your shoulder, recognizing the parts you struggle with and pushing you over those hills. Once it clicks you can fall back on your experience again.

DirkZz left a reply on Laravel Training

@teckel Ask your colleagues at your company what Laravel does and why they have chosen to use it. Your arguments are completely contradicting each other.

If you see no added benefit of having for example a well maintained set of functionality that takes away a lot of mundane tasks in an elegant,extendable, and tested way which is easy to teach to new people (well.. most people..) then no, a framework isn't for you, and Laravel isn't for you.

If what you are saying is that you don't need routing, hate mvc, dislike ORM's, hate templating engines, can't or won't work with composer then you are quite frankly a complete waste of time to a lot of teams. I don't mean this as a personal attack but from my point of view you would be very difficult to fit into any team.

"Im sure if you've never programmed something from the ground up, and have always needed a crutch to program with, Laravel may be required and understandable. "

You are in for a treat then when you start exploring some of the other frameworks out there that are almost completely set in stone when it comes to the structure of your application.

;) A good thing thing then that Laravel uses something like Composer, you will love it when you have actually build a lot of applications from the ground up. btw; You can even use it to make your own code re-usable across projects and keep them up-to-date fairly easily. (assuming you use git?)

Although I can see your personal benefits of an entire company relying on your custom build framework and depending on you to maintain it. The job security that comes with it is quite nice.

Till the day they toss it in favor of Laravel, Symfony, Zend or whatever framework, somehow it is easier to recruit staff and make them productive in a short timespan when applications are build on one of theses frameworks.

22 Apr
2 years ago

DirkZz left a reply on Passing Different Functions In The Same View

I think you are looking for View Composers:

https://laravel.com/docs/5.4/views

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:

https://www.algolia.com/doc/guides/search/filtering-faceting/#filtering

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 type at turtle speed. For me it is perfect as is.

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

https://laravel.com/docs/5.3/authentication#events

''' 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\LogSuccessfulLogin', ], '''

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

https://laravel.com/docs/5.3/authentication#events

24 Nov
2 years ago