Member Since 3 Years Ago

Experience Points 1,755
Experience Level 1

3,245 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 3
Best Reply Awards 0
Best Reply
  • 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


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    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.

07 Sep
2 years ago

ilaurens left a reply on Caching Eloquent Models Since Laravel 5

Yes, but that is the eloquent function that caches the query. The Cache still has the remember function.

ilaurens left a reply on Caching Eloquent Models Since Laravel 5

Of course, it could work without any issue. When you call "->get()" You will receive the results, this will be cached by "Cache::remember", so it's pretty much just getting (when it already exist) and putting data (when there is no data and/or cache timer is expired) in cache.

ilaurens left a reply on Caching Eloquent Models Since Laravel 5

Well, if I have to guess, it's less open and you are forced to use a set structure, or something like that I think. Maybe :P?

$value = Cache::remember('users', $minutes, function() {
    return DB::table('users')->get();

I think that something like this will be the alternative, for that remember function (or replacement), seems easy enough. It even faster because it just caches the content (so subquery's don't need to be cached manually), though I can imagine people might have trouble with the naming, haha.

ilaurens left a reply on Caching Eloquent Models Since Laravel 5

@BartHuis I never used it, because I never actually needed it, website was spinning without issue, but I did make note on that feature when the website got bigger. It suprised me to hear that it got removed, it's handy, easy to use and can give website a big boost, shame on you Laravel!

I did read that there was a package that allows you to have that function back again: Disclaimer: Did not test, nor do I know the author.

Got no idea why they would delete a function like that ;(

05 Sep
2 years ago

ilaurens left a reply on WhereHas Where Multiple (must Contain)

Oke, I found something, it seems like this does the trick, but I think there must be a better way to do this.

        $keys = array_keys($request->genres);

        $list = Movie::with('genres');

        foreach($keys as $k => $v) {
            $list->whereHas('genres', function ($query) use($v) {
                $query->where('id', $v);


It kinda feel like this will give a lot of overhead, is this the best way? Any other & better ways will be appreciated :) Solution mark will go to the best.

ilaurens left a reply on WhereHas Where Multiple (must Contain)

@InaniELHoussain Thank you, but that does not seem to work either ;(

Tried something like that already, but did not work before either, did test it though, just to be sure :)

I think where selects a single of many results, and when id is 2, it cannot be 5 for example. ;(

04 Sep
2 years ago

ilaurens left a reply on WhereHas Where Multiple (must Contain)

Yes, I tried it already, whereIn was also my first guess :P

The Keys as reference: array(2) { [0]=> int(6) [1]=> int(80) }

The first result will return: 6 | 21 | 76 | 10 | 15 | 13

You can see the '6' that is correct, but there is no '80'. Both must exist for it to be selected. I think whereIn detect whether id is inside the array, which is not good for my purpose (because all of it must be AND WHERE).

Thank you for your time btw, :)

ilaurens left a reply on WhereHas Where Multiple (must Contain)

I got a form with genres that you can select with checkboxes, it will give a array with genre id's on submit to the controller.

Those id's must be used to select movies (all of the id's must exist within the results of the movie -> genres).

In other words I select Adventure(id:1) and Action(id:2), it will select all movies that contains both genres (1 & 2)

ilaurens left a reply on WhereHas Where Multiple (must Contain)

@InaniELHoussain that will select any movie that contains any of the keys, since genres is selected (it must contain all keys).

@jekinney The (with, limit) is just for debugging, other than getting the movies, it's not needed at al. I've tried the has function, but... To no avail, perhaps I'm not thinking correctly regarding it :P?

ilaurens started a new conversation WhereHas Where Multiple (must Contain)

I'm in a bit of a situation with whereHas, the problem is I got a array with keys, I need to use those selected key to find results that contains all (ids that is contained within the array). The problem is it works with one, but when having more than one it does not work.

It seems when using where('id', 3) it will select that one, but when you use another where('id', 5) it does not work (it probably uses the same record for that)

This is the code:

        $keys = array_keys($request->genres);

        $list = Movie::with('genres')->whereHas('genres', function ($query) use($keys) {
                $query->where('id', 3)->where('id', 5); // testing it manually, but it must be done with the value in "$keys"

It also has a pivot table, for relationship based on movie_id. If there is any other way, I'm hoping to hear that too. My preference is the best, clean and without much overhead.

Thank you in advance :)

30 Aug
2 years ago

ilaurens left a reply on List Based On Pivot?

A little example how I have it now, it's easier to get a expectation of the outcame I wish to have:

$ids = Movie\Follow::where('user_id', \Auth::id())->get(['movie_id'])->lists('movie_id')->toArray();

dd(Movie\Post::whereIn('movie_id', $ids)->orderBy('published_at', 'DESC')->get()->toArray());

Yes, It's kinda ugly, but it's still a test code :P

ilaurens started a new conversation List Based On Pivot?

I have a small structure as example I will use it to indicate how the table work: movies -> movie_follows (user_id, movie_id @pivot) -> posts (id, movie_id)

The follow works fine, I can get the following movies without a problem, but now I need to get the posts based on the following movies. I need a list with only posts that exists within the pivot. I have been thinking extracting the followed movie id's, but in general it can be thousands, which I do not think it's a smart thing to do.

I'm using this for an RSS feed, I need a list of the newest posts based on 'published_at',

Got any clue what the best way to implement this is?

27 Jul
2 years ago

ilaurens left a reply on Blade Directive Variables

Thank you d3xt3r,

Made a assumption that I was working correctly, I did try it in that manner but it did not work either, but I probably made a mistake(during that attempt). Whoops ~

Makes sense, that the directive is a string and it will replaced by the 'shortcode' of the directive. Thanks :)

ilaurens started a new conversation Blade Directive Variables

It has been a while that I have been working with a blade directive, but I got a small that I cannot seem to find out why. It is probably a small issue or might be my fault, sight

I was experimenting a bit, and I got this code: ''' @section('content') @cmsContent($page) @endsection '''

The Blade directive looks like this: '''' \Blade::directive('cmsContent', function($page) { dd($page); }); ''''

But the output it gives me is: ($page)

Anyone got a clue what can cause this? $page exists, it's an object. The directive is in appserviceprovider -> boot

17 Jul
2 years ago

ilaurens left a reply on Laravel ACL

I did not add a creditcard, and I guess they are also not free. So nope, did not do that.

If you ment separating with groups in the route, I know that is possible, I know I can also use acl that way, but I made a small permission system that received the data from database. So that it can be changed on the website itself, instead of using it hardcoded.

It got three groups: Administrator, Moderator and User.

The first idea was to add another role called 'Guests', so that I block all request, unless it is stated within the system roles & permissions. But the problem with that is, it uses the "User" to get the roles, so I made a workaround for that. But then a second issue came, The class GATE does not seem to work when not authenticated. It keeps denying access, as far I know it's related to the gate using auth, which keeps messing it up.

It keeps giving false, while it could be there.

ilaurens left a reply on Laravel ACL

If you ment the one with policy, then it's different. Cannot seem to find the others.

ilaurens started a new conversation Laravel ACL

Will keep it short, made a big explanation but after posting it redirected me and lost all...

I am using for my ACL the following roles (admin, mod, user), this works great but the problem is unregistered users aka guests. Every rule that I add will block the guests users, but only with that it's just asking problems, since when coding and adding permissions can make you forget something, so that it might get abused by a guest.

In short, everything is unprotected, unless you add the rule to the gate of laravel. I want it to do it the other way, everything is blocked, unless I add a rule that allows it(can be a hassle but is fail-safe).

That is what I'm using

            foreach ($this->getPermissions() as $permission) {

                $gate->define($permission->name, function ($user) use ($permission) {
                    return $user->hasPermission($permission);

I also tried this, but It does not work, and I red aftewards that GATE also uses the User or auth model, so it remains the same.

if(\Auth::guest()) { // Not logged in @guest

            $guestPermissions = RoleModel::with('permissions')->whereId(6)->first();

            foreach($guestPermissions->permissions as $guest)

                $gate->define($guest->name, function ()  {
                    return true; // We are here to give permissions


Anyone got a idea?

21 Oct
3 years ago

ilaurens left a reply on Parse String To View

@thomaskim Incidently pressed the awnsered my question button, but well, I guess it's the most interesting post, so I will keep it that way.

You are right, it's indeed a good choice to use normal files, did not see it that far yet.

The plan was to use a good textfield with markup's so that it's easily to manage within the control panel, it's not ment so that it will keep all views inside the database, but only those used with the pages.

It seems both have their own benefits, but indeed the theme idea, I did not really think about that one, you are absolutely right!

I will continue with views based, thank you :)

ilaurens left a reply on Parse String To View

@pmall Because it's easier that way. Why would I want to add an database entry and a seperate file with view data? While I can have everything at one place, in the database.

Because now I have to create, edit and remove the file, while this could easily be done, if it stayed as a bundle in the database.

Well, it's not a problem, actually, but would have loved to keep it together.

ilaurens left a reply on Parse String To View

@ohffs Good suggestion, will consider this.

But since I'm getting used to the blade system, my preference would be to stay at blade since it is build in, and Twig requires a learning curve and a third party app.

ilaurens left a reply on Parse String To View


It's a CMS system, the template files are located in a database, and I would like to render it. Only authorized people is allowed there.

ilaurens left a reply on Parse String To View

Well, seems like the above idea introduced me to some problems with caching, the same file is called over and over, so the caching kicks in. :P

return view('Cms::page.view') ->with('page', $page);

ilaurens left a reply on Parse String To View


To put it bluntly I am working an a CMS, or well, at least gathering a bit idea's before starting with the project. The blade syntax is stored in my database, and would like to use the received data the same way as calling a normal blade.

Normal way: view('')

What I would like view($bladeContent) --> obviously, it does not work that way.

So I would like to render the view from the database(string), instead of files.

ilaurens left a reply on Parse String To View

I have been playing around for a bit, what do you guys think about this approach?

        \Blade::extend(function($value) use ($page) {
            return preg_replace('/@cmsview/', $page->html , $value);

It is much better than that eval goody, but still doubting, about storing it to the database vs local file storage, I can also make files on the go.

Since it is cached anyway, it does not matter whether I use the database or file, but database would have been the easiest choice.

19 Oct
3 years ago

ilaurens left a reply on Parse String To View

Sorry, I suck at explaining things.

I would like to use the blade system, but instead of using view('test.file.path'), I would like to inject a string that needs to compile directly.

The view: 'test.file.path' does not exists, but the content is located in the database.

ilaurens left a reply on Parse String To View

I was playing a bit, for fun ~ but I would like to avoid code like this:

'''' public function lol($content) { ob_start();


    $content = ob_get_clean();

    return $content;



ilaurens left a reply on Parse String To View

I ment literally taking an unparsed content from the database, and throwing it inside a view and parse it like it normally works.

I cannot find anything that works with a string, but I can find functions that works with files(this is something I do not want).

ilaurens started a new conversation Parse String To View

I am taking data from the database, and would like to place it inside a view and render it.

Does anyone know how to do this without using a package from someone else.

07 Oct
3 years ago

ilaurens left a reply on We Provide Expert Laravel Developer @$8/hr Only.

No, it's advertising, your post is spam, literally. Sorry, had to say that :P

06 Oct
3 years ago

ilaurens left a reply on Can Not Get The Full Name Of The User

Did you perhaps login, after that changed the name to a full name, and afterward tried it with this code?

Might be a caching problem. But the code itself seems good.

ilaurens left a reply on Existence Of App Instance & Modules

I decided to make an alias for the modules and use Module::getModule('modulename') to receive the appropriate module.

I hope that some will share idea's or got tips. Since I'm still learning. Thanks ~

05 Oct
3 years ago

ilaurens left a reply on Missing Model::find() Method? Or Just Me

That is why they ask for a code, but well, since you want to figure it out yourself, you couldn't have created the topic in the first place.

ilaurens left a reply on How To Set Home For Different User Roles

You can take a look in the RedirectIfAuthenticated class that is located inside the middleware folder. I think that is the correct class.

ilaurens left a reply on MethodNotAllowedException In PATCH Request

I do not work with the Form/HTML class, but it seems it's not directly supported.

You can add this to the form:

<input type="hidden" name="_method" value="PATCH">

That might solve the problem.

04 Oct
3 years ago

ilaurens started a new conversation Existence Of App Instance & Modules

I am creating a small module system, I thought it would be handy to make it accessable from the view & controller for extra functions like getting the menu.

I'm using this to register it:

$this->app->instance($serviceName, $object);

And receiving the content with:


This works, but when the 'Foo' class does not exist, it will throw an error. I searched for a bit, but I could not find a function that checks for the Existence.

The questions are:

  1. Do you know of a function that checks if the 'app('foo')' exists without try & catch?
  2. Is there a better way to do this, I'm using app for a module object, but is it really a correct way of doing things?
13 Sep
3 years ago

ilaurens left a reply on Has Many With Lists?

@sid405, I never knew Laravel had such behavior, nor can I remember reading this, thank you I will keep this in mind!

The reason for the 'movie_' in front in the name is because I let that act as a suffix, it keeps things seperated, because I'm sure there will be more genre tables, also it's a part of something that will be reused, so it's easier seperate. Or so I think :P

ilaurens left a reply on Has Many With Lists?

@sid405 Thank you, this works the way I wanted it to work, and I learned a few things, Thank you!

It is indeed pivot, I came to that conclusion a while back, but I was not sure, was a half day thinking about a good name :P genres -> because there were multiple list data inside this, and item -> because it was single data.

By the way is this naming fine? movie_genres --> contains the actual data(last called movie_genres_item) movie_genres_pivot --> contains the list data (last called movie_genres)

ilaurens left a reply on Has Many With Lists?

Sorry about that, I started writing a while back, but suddenly there was a crash and lost it all CRY

This is the one involved, and any tips for naming is appreciated. I definiatly suck with naming, :P


use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMovieGenres extends Migration
     * Run the migrations.
     * @return void
    public function up()

        Schema::create('movie_genres', function (Blueprint $table) {



        Schema::create('movie_genres_items', function (Blueprint $table) {

            $table->string('title', 50);

        // The relation
        Schema::table('movie_genres', function($table)


     * Reverse the migrations.
     * @return void
    public function down()

ilaurens left a reply on Eloquent Dont Work On Production Site

You are creating the query, but not getting the results, use:

$workstations = Workstation::where('availability',1)->get()->sortBy('price');

I also suggest that you use another way to get and order the data, though it depends on usage.

You could preferably get only the needed data, not all the data and manually sorting. The database can sort it while retrieving it.

I suggest you to use something like this:

$workstations = Workstation::where('availability',1)->orderBy('price')->get();

ilaurens started a new conversation Has Many With Lists?


I will try to keep it short, had a big description but the browser crashed, and I lack time at the moment.

I'm using hasmany on a genre table, the hasmany is called on a list with (id, movie_id, genre_id), and this works as expected, but the problem is that I need to call another one with the real content based on genre_id.

I'm not sure how to do this, I did after the hasmany()->with('genres'), that seemed to work, but then I got two dimentions instead of the expected 1 dimention array.

What is the best way to resolve this issue? I know it's because of with, but hasmany->genres() does not work. I tried morph, but I'm not sure if that is the correct way to work with, also since I could not get it to work correct, that is why I'm posting this.

Thanks ~

29 Aug
3 years ago

ilaurens left a reply on Database Time

I nearly forgot :(

        $test = Test::where('lasttime', '<=', Carbon::now()->subMinutes(1))->get();

The subMinutes has a value of: 1 at the moment, but it requires to get that value from the database in the same table, it is called 'timer'.

Do you guys have an idea what the best way is to handle this? Is there any way to do this without WhereRaw?

ilaurens left a reply on Laracast - Not Impressed

Hi @CarlosJa It can indeed be hard in some cases to follow a video, well, might be the case for me because I prefer to read docs or search for tutorials instead.

Make sure to understand what and how MVC works, it will make things a bit easier when learning. You might as well use basic routes in the beginning like: ,,,, Route::get('view/{id}', 'ArticleController@show'); Route::post('store/{id}', 'ArticleController@store'); ,,,,

After you have a basic understanding, you might want to do something more advanced with routing, well, I'm not that far either :P

Might be confusing in the beginning, Like I said, get a good understanding what MVC is, and follow some small tutorials and use basic things first, before going to deep.

I never actually used Laracast, because I do not have the patience to watch an episode full of talking, but I can imagine that it can be pretty complex and confusing, when you do not have a basic understanding of it. You can do a lot of things with routing alone, while that it's still a small part of a big system.

I'm sure in the end you'll love Laravel! Good luck.

ilaurens left a reply on Database Time

@StuffedGoat This would probably as far I know the most normal awnser to this question, I did think about this already, but I'm thinking a bit ahead, two websites in different countries means different lokale, and this can cause problems when using using it with the database time, Well, I can use the same lokale in every country, but I think this defeats the purpose, I guess.

@skliche Possibilty indeed, will remember this one, but it's not exactly what I am searching.

Thank you for the replies, appriciate it!

Perhaps I'm overthinking things, well, at the moment what I am thinking is that it might be better to keep the timezones the same, for example the defaults 'UTC', and when retrieving the date for display, I can convert it to the required format / timezone. This might be the better way, I think.

ilaurens started a new conversation Database Time

I am currently having a bit of a problem, there are multiple ways to get results that is older than a certain time.

When using the Carbon, it will use the local time of the locale configs, but when using now(), it will be using the time of the database server. This can have a mismatch.

Let's say there are two servers, one is in The US and the other is in The Netherland, the time difference will be two or three hours, to centralize this problem, I thought that using the database's time(now()) might be a better idea.

What do you guys think about this?

I am currently using this two code, The carbon code looks neather, but I think the DB::raw might be a better choice, is there better functions to use the databases time?

        $test = Test::where('lasttime', '<=', \DB::raw('DATE_SUB(NOW(), INTERVAL timer second)'))->get();
        //$test = Test::where('lasttime', '<=', Carbon::now()->subMinutes(1))->get();

-- Another question, is there any way for created_at and updated_at to use now(), of course without to much hassle?

20 Jun
3 years ago

ilaurens started a new conversation Scaffold Is Niet Setup Correctly?

I recently started with Laravel and started directly with Laravel 5, since I'm still learning, I keep repeating parts by deleting the whole project and start anew.

But a few days ego, When I tried to re-install the project, it does not seem to have the scaffolding working.

There is no scaffolding in the routes, when adding directly it just throws an exception not found. Any idea? I used this for the creation:

composer global require "laravel/installer=~1.1" composer create-project laravel/laravel --prefer-dist

~ Sorry about that Guru, I did not see anything new in the documentations. Could I have used make:scaffolding or something?

This makes me wonder, if they removed it. Any idea?