JeroenVanOort

JeroenVanOort

Member Since 4 Years Ago

Rotterdam

Experience Points 26,900
Experience Level 6

3,100 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 36
Lessons
Completed
Best Reply Awards 18
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.

16 May
1 year ago

JeroenVanOort left a reply on Code Refactor Needed

Yes, there are ways to refactor this. What have to tried so far?

JeroenVanOort started a new conversation EloquentJS: Hidden Treasure Or Nono?

I was alerted to this package: http://parsnick.github.io/eloquentjs/ . It aims to provide the ability to query Eloquent models from JS. This includes using where(), orderBy, etc. It's meant to be used in an environment where you would have a JS front end application which communicates with it's back end via JSON REST endpoints provided by Laravel. Which happens to be exactly what we do for many projects.

To me and a colleague it appears to be a great alternative to something we've developed ourselves: an Angular library fiddled into ng-table that translates the front end filtering and sorting parameters to HTTP parameters and a stack of Eloquent scopes that process these parameters to ultimately return the entities over a REST API. If it weren't so tightly coupled to our projects and it wasn't so hacky, we'd have open sourced it. But we're looking move to VueJS, so we won't develop it any further.

Anyway, a great alternative, so it seems. But EloquentJS has only had 442 composer installs at the time of writing and hasn't been updated for some years. Should we decide to use it, we'd be happy to contribute, so the lack of upkeep wouldn't be a major problem. We could even fork it if the current 'maintainer' does not co-operate.

But the few installs and therefore usages of EloquentJS can mean two things: A, it's a hidden treasure, or B, there's something inherently wrong with it. We can't decide and we'd really like a broader view on it.

What do you think of EloquentJS? Would you use it and why (not)? Can you recommend any alternatives?

27 Oct
2 years ago

JeroenVanOort left a reply on Deadlock Issues

Can you explain when this happens? What are your trying to do?

JeroenVanOort left a reply on [L5.3] Easiest Way To Populate The Edit Form

There is this package: https://laravelcollective.com/docs/5.3/html

It can be use to generate forms dynamically and supports the model binding you're probably looking for.

05 Sep
2 years ago

JeroenVanOort left a reply on Restful Api In Laravel

  1. Go for 5.3: if you're starting from zero, there's no need to use an older version.
  2. As far as I know, there isn't.
  3. We can't help unless you ask questions and tell us what you want to build.

JeroenVanOort left a reply on Angularjs 2 With Laravel Issue

  1. Both AngularJS and Laravel are both common and proven techniques to use for these kind of applications. You should be alright.
  2. AngularJS and Laravel can handle these things. You success mainly depends on your own skills.
  3. You're probably referring to a concept called 'coupling', which should be avoided. You want the Laravel part to be a stateless JSON REST API and you want AngularJS to be a client for it. If you're making it in such a way that you could switch either of those parts for another, you're good. For example, if you've already got and API for angular to use, why would you build a separate API if you want other applications to interact with yours; for the API, there's no difference. Likewise, should you ever want to exchange Laravel for some other framework, Angular shouldn't need to know.

JeroenVanOort left a reply on Running Multiple Queue Workers

I'm not sure, but trying probably won't hurt.

JeroenVanOort left a reply on Validate Child Rows While Save

This would probably help you get in the right direction: https://laravel.com/docs/5.3/validation#validating-arrays

JeroenVanOort left a reply on How To Paginate Relations In Laravel - Help Me (jeffrey Way)

I'd make a separate endpoint for comments. For example, you could use /api/v1/posts to get the post's ID, and then make a second call to /api/v1/comments?post_id=42. In this second call, you can do any pagination you want, including getting more records if the user clicks that button.

31 Aug
2 years ago

JeroenVanOort left a reply on Multiple Domains On The Same Laravel Instance

If you know what you're doing, updating the first project will indeed take some time, but the other ones will go much quicker because you've learned which things to change. First hand experience with about 40 projects on 3 Laravel versions.

I would certainly not recommend running multiple unrelated sites on a single instance of anything, not even Laravel. The mains reasons are complexity, performance and reliability. Writing logic that separates the multiple sites within you're codebase will get messy very quickly. And if you'd want to host one of the sites on another server because of traffic flow, you'd have to move all of them which defeats the purpose of moving. And if one site breaks, they'll all break. The company I work at has, once in it's colourful history of development techniques, tried to build one CMS that would contain all sites they built. It hasn't really ever worked, we're still having to support it and the three reasons above are the ones because of which the project failed.

What you can do however, is to make packages of things your sites have in common. We have packages for the cms (pages, navigations, etc), email templates, blogs, etc. We keep them in separate git repositories and manage dependencies via Composer Satis.

JeroenVanOort left a reply on Should I Use A Separate Controller For Each Page?

In most cases, you will have one controller that handles them all. That controller will generally fetch the page that corresponds with the slug from the database and pass that data to the view that renders the page. This enables you to simply add a record to the database if you want to add a new page to your site.

JeroenVanOort left a reply on Permissions/Roles

From your code I gather that you've successfully seeded your database with Permissions and Roles and that you're wondering how to seed the link between them.

Do you have a ManyToMany relations and table between the Permission and Role models? If so, you can populate that data as describded in the docs: https://laravel.com/docs/5.3/eloquent-relationships#updating-many-to-many-relationships

JeroenVanOort left a reply on Secure Way To Host Laravel Project

What I've done on DirectAdmin servers, is to place the project in ~, remove the ~/public_html folder and make a symlink called public_html to public. This makes sure that the public folder is the only folder actually accessible from the internet.

You could do the same for a cPanel server, but I'm not sure which directories it uses.

23 Aug
2 years ago

JeroenVanOort left a reply on Input Value Different On Server

Can you please post the result of $request->input() on both your development and production environment when calling the same URI?

JeroenVanOort left a reply on Laravel Doubts

First of all, you'll need to create a database. A control panel like cPanel can do that. If you're running a server without a control panel, you'll have to use MySQL's or PostGres's command line interface.

After that, you'll will have to create tables in your new database, to store your data in. Laravel does that by using migrations.

This free series will help you get up and running: https://laracasts.com/series/laravel-5-from-scratch .

JeroenVanOort left a reply on Writing Array To Xml File.

As the PHP docs will tell you, file_put_contents can indeed be used to append to files, but it doesn't do that by default. This will probably work:

 file_put_contents($this->boostStore .'text.xml', $xml->outputMemory(), FILE_APPEND);

JeroenVanOort left a reply on Laravel Doubts

You're asking us to explain everything, while you sit back and relax. That is not how the internet works.

Please explain what you want to do and what you've already tried. Until we know more, I can't do anything but direct you to the Laravel docs.

20 Jul
2 years ago

JeroenVanOort left a reply on TokenMismatchException Instead Of 405

I think I've found out what's happening here.

I set up a vanilla Laravel install and I can indeed confirm it gives the expected 405 when firing an empty POST at /. What's in that Laravel install and is not in our project, are middleware groups. Because those groups of middleware are ran only when there is an applicable route for them, the TokenMismatchException won't be thrown because the application never gets to that point. When moving the VerifyCsrfToken from $middlewareGroups to $middleware however, it does give me the TokenMismatchException and not the 405.

Thanks for helping me find out.

JeroenVanOort started a new conversation TokenMismatchException Instead Of 405

Lately, we've been seeing some DoS attacks on our applications that execute an empty POST on /, probably aimed at making a much sessions files as possible, making the server or account run out of disk space. There is no POST route for / on this application, so I'd expect Laravel to reply with a 405 status code. However, it gives a TokenMismatchException instead (because there is no _token).

After looking in to the code Laravel used to throw this exception, I understand why it is happening, but I haven't found out how to make it behave like I want it to. I don't know of a way to only throw the TokenMismatchException when a POST route is active, because the routes are not yet loaded.

I'd like to know if and how any of you solved this. Sending an empty POST to https://spark.laravel.com does seem to give me a 405 for example.

05 Jul
3 years ago

JeroenVanOort left a reply on Nested Where Clause

The problem is in the orWhere query.

I'd do this:

if($request->get('name'))
 {
    $q->where(function ($w) {
           $w
                        ->where('firstname','like', "%".$request->get('name')."%" )
                        ->orWhere('lastname','like', "%".$request->get('name')."%");
        });
}
20 Jun
3 years ago

JeroenVanOort left a reply on Security Coding Practice

"It is your application, it is up to you." is indeed the best advice. If you're building some in-house mini application that doesn't handle sensitive data, it'd be fine to skip some validation. If you're building a large, public facing application that handles important data that is not to be messed with, unleash all the validation you can find and secure the crap out of things. Overkill is always better than kill, in such cases.

JeroenVanOort left a reply on Running Socket.io Server On Shared Hosting With Ssh Access

The socket.io server will need a port to bind to, which is 80 or 443 in most cases, because other ports can be blocked by client firewalls. Since DirectAdmin will already make it's web server (Apache) run on those ports, you can't run anything else on them as far as I know. If you're just playing around, use a random port number and you won't even need to configure anything in DirectAdmin for the socket server, but if you're planning on building a real life application, I'd recommend to seek or await further advise.

24 May
3 years ago

JeroenVanOort left a reply on Session Data Lost Not Sure Why

What went wrong?

Just this morning a came across an issue with one of our applications where we needed to call session()->save() manually because there was a redirect following the setting of the session data. I wonder of this is the same kind of problem.

JeroenVanOort left a reply on Prevent The Installation And Copy The Laravel Project On Hosting Customer!

Not with an open source license, at least. I've heard about http://www.ioncube.com/, but I've never used it myself or even seen it being used.

JeroenVanOort left a reply on Concurrent Requests Issue

It's certainly different from what I'm suggesting. I don't know enough about DB level locking to give advice about it; I've never had to use it.

JeroenVanOort left a reply on Concurrent Requests Issue

You need some kind of lock. Maybe the simples way is to check if a lock file exists, if not: create it and execute your function, if the lock file does exist: stop executing and return correct error code.

JeroenVanOort left a reply on SSL Problem Laravel 5.0.33

In that case; does the AJAX call go to an https-url?

And what do you mean by "the request won't be able to find the controller"? Do you get a 404? 405?

JeroenVanOort left a reply on Big Application And Big Tables, Smart To Extract Tables?

It all depends on what you want to do with your data. Simply retrieving a few records probably won't be too much of a performance hit when using the right indices. You'd better get a fire extinguisher ready when trying to aggregate ten of thousands of rows of a multi million row table joined to a dozen or so other tables without even googling for 'sql index', though.

I've found that most of times, starting out with the most simple working solution and trial and error after that, is the best way to find the best way. Try to make your best guess at how much data your table will contain, double that, write a seeder for it and start testing and measuring.

JeroenVanOort left a reply on Sending Mail Through A Queue Model Not Found

Please mark you own post as the answer to you question, so that it is clear for everyone that you solved your issue.

JeroenVanOort left a reply on SSL Problem Laravel 5.0.33

What is the value of the action attribute of the login form? Does it have https?

28 Apr
3 years ago

JeroenVanOort left a reply on Laravel 5.2 - DB Raw Query To Show Images For Each Record

@shafiqkr Anyone claiming to like the query builder, should like Eloquent even more. Please learn from the mistakes I have made and use Eloquent. Coming from writing SQL manually, it will take effort to get used to, but so far, I've found very very few things you can't do with it. Believe me, I've written Eloquent queries most developers couldn't fit on their screen. I can't even imagine writing similar things with the plain query builder.

JeroenVanOort left a reply on How To Be A Highly Valued Programmer?

This is always difficult: first of all, there is the difference in culture and economy; here in the Netherlands it isn't possible to live off $400 a month for example, but in many other countries it is considered to be a reasonable salary.

But the second thing is even harder: judging the level of someones capabilities. 1,5 months for a 'fully functional website' can be very slow or very fast, depending on what you're building; Facebook would take you much longer and a site for next door's grocery shop with a dozen pages would take much less time. And then there's build quality; I've seen the bad and the ugly, and I have admired developers for their genious.

18 Apr
3 years ago

JeroenVanOort left a reply on How Often To GIT COMMIT During Development?

Some guidelines in the company I work at:

*When you're working on one thing, commit when finished, before starting something else. *If you have any overlap in tasks, create a branch for that feature/bug. *Always commit to the development branch, the project lead will merge to master, test and deploy.

16 Mar
3 years ago

JeroenVanOort left a reply on Best Way Of Inserting 100k+ Entries In MySQL

Aside from MySQL's command line utilities, there are some Laravel ways to speed this up. First of all; transactions. Not only can this be used to make sure all queries are executed if any are, it will also make large amounts of inserts perform better because of the queueing.

Furthermore, I suggest you make this process and artisan command. In most cases, this well get you around PHP's memory limit, since the CLI limit is usually higher than the limit for HTTP requests.

JeroenVanOort left a reply on Executing A View Composer Only Once

Eureka!

What I forgot about singletons is that while the same object is returned every time, the compose function is still called multiple times. With that in mind, I've found this solution:

In ComposerServiceProvider:

public function register()
    {
        $this->app->singleton(\App\Http\Composers\CountriesComposer::class);
    }

And the composer class itself:

namespace App\Http\Composers;

use Illuminate\Contracts\View\View;
use App\Country;

class CountriesComposer
{
    private $countries;

    public function compose(View $view)
    {
        if (!$this->countries) {
            $this->countries = Country->all();
        }

        return $view->with('countries', $this->countries);
    }
}

JeroenVanOort left a reply on Laravel Where Clause Help

$query->where('type1', $type1 == 1 ? '=' : '>=', $type1);

JeroenVanOort left a reply on Convert All Eloquent Model 's Fields To String

I'd be inclined to tell them to just suck it up and get their shit together, because I don't think converting data types is the bottleneck in app performance.

Imagine what hell you'd have to go through when the mobile developer decides he wants to show a different date format to users in certain countries: would they include the country in the API request and make you do the conversion instead of doing that minor amount of computing client side?

Anyway, at least you now know what to do in Laravel to make this "work".

15 Mar
3 years ago

JeroenVanOort left a reply on Sanity Check On Time Taken To Build Resource Routes

This sounds like a problem I've helped solving before. At my company, we've created an admin panel that uses Angular as a consumer of a Laravel REST API. We use a generator for doing the repetative work of making migrations, models, requests, controllers, routes, etc. We chose this path because we need the freedom of being able to use Laravel to it's maximum potential. Generate once, tweak wherever needed.

Sure, when starting a new project a developer can be generating and tweaking files for a day or two, but by then we have everything we need to start importing data and building a front end.

I would love some kind of framework on top of Laravel to be able to take a declaration of a project's models and relations and do the rest automagically, but I've not been able to think of a way to handle things like multi-language, parent/child constraints, eager loading, etc. For simple things this might work, but after over a year of working with this full time we know that things get complicated very fast and we don't know of a way to handle that in an automated way.

JeroenVanOort left a reply on WhereHas VERY Slow

@Prez Sure, that would work. However, without the index I would expect it to be equally slow.

JeroenVanOort left a reply on WhereHas VERY Slow

I suggest that you put the indexes in your migrations. For example:

Schema::create('regions', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('country_id')->unsigned();
            $table->foreign('country_id')->references('id')->on('countries')->onUpdate('cascade')->onDelete('cascade');
            $table->string('display_title', 75);
            $table->timestamps();
            $table->softDeletes();
        });

JeroenVanOort left a reply on WhereHas VERY Slow

Do you happen to have MySQL Workbench available? When optimizing slow queries, I mostly copy the SQL from the debug bar, paste in Workbench and run the EXPLAIN command. It visually shows what MySQL is doing in the background.

Does replacing ->paginate(10) with ->limit(10) reduce the query time? Then at least we know where the problem is.

JeroenVanOort left a reply on JavaScript Auth::user()->id Non-object Error

I'm sorry, I overlooked that.

Please try


if (Auth::check()) {
    do your thing
}

JeroenVanOort left a reply on Executing A View Composer Only Once

I thought of that, but for this specific project the invalidation of the cache would be very complicated. The navigation we're rendering is dependent on about 7 or 8 models, which would all need triggers to invalidate the cache.

For now, I consider that to be more work than trying to run the composer only once. We will do it if there if performance is a major problem and if there is no other option.

JeroenVanOort left a reply on JavaScript Auth::user()->id Non-object Error

Well, than the behaviour is as expected. Auth::user() will return null when no user is logged in. Accessing the id attribute of null results in the error you reported.

Use Auth::check() to see if someone is logged in. Then you can use Auth::user() safely.

JeroenVanOort left a reply on Security On Resource Routes

You may want to look in to this.

JeroenVanOort left a reply on How To Deploy Laravel 5.1 Project On Production Server?

What are the steps you've taken to solve this yourself?

Do you already have an account on some server, and if so, it is sftp/ssh or just plain ftp?

JeroenVanOort left a reply on Convert All Eloquent Model 's Fields To String

You can do this by filling the $casts attribute as documented.

Why would you want to do this explicitly? Just wondering. My gut feeling says there is a more optimal way to solve whatever problem you're looking into.

JeroenVanOort started a new conversation Executing A View Composer Only Once

I'm working on a project where we have View Composers attached to multiple views rendered on the same page. The composer and it's queries are executed multiple times. I want it to run only once to optimize performance.

I.e. the ContactPageComposer might look up the link and contents of the site's contact page and can be attached the top and bottom navigation views. However, the ContactPageComposer would be ran twice.

I've looked around and some say it can't be done and a Laravel 4 solution doesn't work with our L5 application.

I feel like there is a possibility to do this, but I haven't found it yet.

JeroenVanOort left a reply on Multiple Sql Queries With One Sql Connection

Before asking this, you might want to research if Laravel works as you assumed. I don't know for sure, but it would be very un-Taylorian if Laravel would connect and disconnect for every query and therefore I think it doesn't. I've made import commands with Laravel that run many hundreds of thousands of queries and I've never seen any report on my servers that connections are not reused.

I guess you could either dive in to the Eloquent source code or you could log the connects and disconnects on your server while running a command/request that does a dozen or so queries.