GertjanRoke

GertjanRoke

Member Since 1 Year Ago

Kampen, The Netherlands

Experience Points 17,260
Experience Level 4

2,740 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 103
Lessons
Completed
Best Reply Awards 11
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.

22 Mar
3 months ago

GertjanRoke left a reply on Getting Null In Eloquent Relation Data After 3 Records !

@princeoo7 add ->toArray() after the paginate(10) part like the code below

public function index()
{
    return response()->json(
        [
            'blogs' => Article::with(['author', 'moderator'])->paginate(10)->toArray()
        ],
        200
    );
}
07 Mar
4 months ago

GertjanRoke left a reply on How To Access Seeder Data From Controller

@nhayder you can just new up the seeder inside your controller and get any public properties or run the run() method.

It would look something like this:

$seeder = new \Database\Seeds\WantedSeeder();

$seeder->run();
06 Mar
4 months ago

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 aaah now I understand. the short answer is that phpunit will not convert it.

The layer that Laravel placed around phpunit will never change "" to null thats something you need to be aware about when you are testing. So it is good that you know the middleware of Laravel those stuff like that and for your test you need to keep that in mind that sometimes Laravel change the value you submit or get back out of the database, because of a middleware or if you have a casts on you eloquent model that will change a value.

For example if you have a boolean inside your database stored as a 0 and 1 you can casts it to false and true within your model, but when your are testing if the value is true in the database you need to look if the value for that key is 1 instead of true.

05 Mar
4 months ago

GertjanRoke left a reply on 419 Error Caused By Token Mistmatch.

@stubbs on which version are your working of Laravel? I saw that the phpunit.xml was changed for 5.8 to:

 <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
        <server name="CACHE_DRIVER" value="array"/>
        <server name="MAIL_DRIVER" value="array"/>
        <server name="QUEUE_CONNECTION" value="sync"/>
        <server name="SESSION_DRIVER" value="array"/>
    </php>

The <env part is replaced with <server.

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 did you watch the video's of jeffery way where he is building stuff using TDD like "Build A Laravel App With TDD" or "Let's Build A Forum with Laravel and TDD"?

It are really good video's on how you should think about TDD and if you understand it maybe find some video's of Adam Wathan on YouTube of Vimeo, he has some great TDD video's but it's better to view them after you know some more about TDD

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 if the form input or textarea is left empty it will store null, this is because of the middleware you found called ConvertEmptyStringsToNull this middleware will indeed trim and convert a empty string like "" to null.

So for example your description form field can be nullable because your validation says so, so when you do not fill in the description field inside your form Laravel will convert the empty string to null and will store that inside your database, if you give it a string of course it will save the string you gave it.

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 it depends on what you want, can the body be empty in some cases or those it always needs to be filled.

But the problem with your test is that the values do not match with the data inside your database.

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 your almost there, I think the problem is that in the data you have inside $attributes the value of description and body are "" and not null.

But I don't know how picky phpunit is, but with the mindset that phpunit is for strict testing I think this could be your problem.

The rest looks oke.

GertjanRoke left a reply on 419 Error Caused By Token Mistmatch.

@stubbs I think what the problem is that your config are cached, so maybe run php artisan config:clear and then run your test again.

The documentation also said something about it in this part: https://laravel.com/docs/master/testing#environment

GertjanRoke left a reply on Whats Wrong With My Test Case In TDD ? Please Help Me Understand !

@princeoo7 phpunit could'nt find the category_id inside your database so thats why it returns with a error.

phpunit is looking for everything you said by using the $attributes and if there is missing one of the keys or the value's do not match it will fail, like in your case with the category_id

GertjanRoke left a reply on Array Validation Rules Based Off Sizes

@xtremer360 any progress on your validation problem?

28 Feb
4 months ago

GertjanRoke left a reply on Array Validation Rules Based Off Sizes

@xtremer360 maybe by merging your rules? I never tested if having 2 of the same key inside your validation rules work or that it pick up the first key.

'array1' => [
    Rule::requiredIf(function () {
        return count($this->array2) <= 1;
    }),
    'required',
    'array',
    'size:2',
],
'array2' => [
    Rule::requiredIf(function () {
        return count($this->array1) <= 2;
    }),
    'required',
    'array',
    'size:2',
]
26 Feb
4 months ago

GertjanRoke left a reply on Array Validation Rules Based Off Sizes

@xtremer360 I think the only option it to write your own logic using the required if rule.

Take a look at the docs: https://laravel.com/docs/master/validation#rule-required-if

GertjanRoke left a reply on Error Messages Are Not Shown After Validation

@najmulcse do you have a ad-blocker installed on your browser? I had a same problem and the ad-blocker reloaded my page really fast and because of that the error messages were gone.. atleast take a look at your network tab and Preserve log on

GertjanRoke left a reply on $loop Variable In Vanilla Php?

@thewizardguy you can use array_keys() in a way like this:

array_keys($addresses)[0] == $key;

In this way the $key that matches you always know it is the first one.

09 Feb
5 months ago

GertjanRoke left a reply on Check If User Is Not Owner Of Post, And If User Owner Of Comment Parent In Custom Request

@dronax maybe it better to look at it the other way, check if the current user is the owner of the post.

And it will help if you do it in steps, so dump() every check one by one so you see what is happens.

public function authorize() { dump( Auth::user() ); dump( $this->post->user_id !== Auth::user()->id ); ... }

In this way you can better understand what is going on.

02 Feb
5 months ago

GertjanRoke left a reply on Use Route Parameter As A Model Name?

@miwal maybe this works:

use Illuminate\Database\Eloquent\Model;

...


public function show(Model $conent) {
 
    return $content->render();          // method on model that does return view(); (just the plan at the mo.)
                             
}

Maybe in this way with route model binding Laravel will fix your problem, you may need to change your routes for the correct class params.

By the way I had no time to test it out.

22 Nov
7 months ago

GertjanRoke left a reply on Home Route(/) Not Working On CPanel

@petritr I'm happy for you it works now! Happy programming from now on!

21 Nov
7 months ago

GertjanRoke left a reply on Undefined Variable: User_id

@vesunar like @aurawindsurfing already told it is probably a problem because you used ->withUserId('user_id') I don't think that is supported on the view function you need to pass the variables as the second argument of the view function or with the following syntax:

return view('adminContacts.index')->with( 'user_id', $user_id );

OR

return view('adminContacts.index', ['user_id', $user_id]); (or with compact() )

GertjanRoke left a reply on Resource Route Parameters Error

@AMK - @amk what tykus means is that you can't specify your query parameters within your routes and also not inject them in the variables of your index function.

If you want to make sure the city has been given then you need to validate it.

For example you can do something like this:

use Illuminate\Http\Request;

...

public function index(Request $request)
{
    $request->validate([ 'city' => 'required' ]);

    dd( $request->get('city') );
}

But there are more ways then this how to validate the input, but you need to checkout the documentation of Laravel.

GertjanRoke left a reply on Home Route(/) Not Working On CPanel

@petritr is there a index.html in your public_html folder? I not sure because I can't test it but I heard some time ago that cPanel prefers a index.html above index.php but i'm not sure if this is the case today.. but it's worth to check.

GertjanRoke left a reply on Debugbar Shows Thousands Gate Queries

@wizjo oh 1s is not so bad, did you also checked your network tab? Maybe you can see something there what makes it slow.

Maybe something to keep in mind, debugbar will also consume alot of time.. it is a very handy tool but it makes your site also slower when you have it enabled.

GertjanRoke left a reply on Debugbar Shows Thousands Gate Queries

@cronix good point and if it still is low, you can try to test how much time a part of your code takes by placing a dump before and after the part of code you want to test.

Example:

dump( date( ‘H:i:s’ ) );

foreach( ... ) {
    ...
}

dump( date( ‘H:i:s’ ) );
20 Nov
7 months ago

GertjanRoke left a reply on Debugbar Shows Thousands Gate Queries

Hello @wizjo, like click said you can try to cache it, but I think eager loading is what you need. So here is the link to the documentation of Laravel, I think if you read this it will help you alot with your queries.

https://laravel.com/docs/5.7/eloquent-relationships#eager-loading

Just for your information the problem is that you run a query inside a foreach, this is done by this part: $this->role->name.

Good luck debugging.

GertjanRoke left a reply on Home Route(/) Not Working On CPanel

@petritr I don't have any experience on cPanel but maybe this post will help you: https://www.rosehosting.com/blog/how-to-install-laravel-on-a-cpanel-server/

And if you don't have a SSH connection maybe this blog can help you: https://dev.to/asapabedi/deploying-laravel-5-applications-on-shared-hosting-without-the-use-of-ssh--16a6

PS Not a big fan of moving everything a folder up but if it works.

19 Nov
7 months ago

GertjanRoke left a reply on How I Can Configure My Middleware After Login

@Usmanfarzand maybe you need to watch the video Jeffrey posted and I think this and the 2 video’s after that are really helpfull for you.

https://laracasts.com/series/laravel-from-scratch-2018/episodes/25

GertjanRoke left a reply on Send Mail Through Window Modal Form

@barbaratackaba a question do you get redirected after you do a post to this route or do you get a Laravel error?

If you are redirected there is a big change that everything works but you only needs to chech if all your config settings are correct as well as in your .env and also the config file in the config/ folder.

And also check your log files like @snapey said.

Good luck.

16 Nov
8 months ago

GertjanRoke left a reply on Dropzone With Laravel Form

Also you want the value of the images field to be a image, but your field is a hidden input so that can never contain a image or multiple images, you need to change it to a type="file" input field and maybe hide it with css if you don't want to show it

GertjanRoke left a reply on Send Mail Through Window Modal Form

@barbaratackaba I think you need to change this values in your .env file, mailtrap changed there smtp server somewhere of the beginning of this year.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525

I think this will help alot.

19 Jan
1 year ago

GertjanRoke left a reply on Mail Send Not Working

You could try to set a return before the Mail::send part. If I am correct Laravel will return the html from the mail template filled with your variables.

Maybe you can see what goes wrong there?

GertjanRoke left a reply on Maybe Add A Default Markup For A New Discussion

Is there any change that @JeffreyWay will even read this and maybe consider this a feature?

11 Jan
1 year ago

GertjanRoke left a reply on Redirecting Back To Intended Laravel 5.5

@FutureWeb are you using the original middleware? Because there is wherr the magic happens

03 Jan
1 year ago

GertjanRoke left a reply on Maybe Add A Default Markup For A New Discussion

@mstnorris I understand what your saying and appreciate that you made that great guide, but to be honest if been using this forum for more then 2 years and I never found your post about this subject and I think new people will also never find it. Just because there are only interested in finding the correct answer for there question and not thinking about “what is the correct way to ask my question?”.

So thats why I brought this up and you can call it boilerplate or guidelines, or what people think the best name is. it is just a easy way to help people ask questions with better pre information without reading more then 300 lines of information.

Once agean your guide is great but for a person like me with dyslexia, I'm on the second paragraph and my mind will say forget this just ask the question. Not because I’m lazy but my brain doesn’t work like that. So yeah you could call it my problem but in the couple of days that I have been helping out I also see people take that approach and just ask, instead of first figuring out what the best way is to ask the question.

I'm not trying to say your way is wrong, but I just see a habit of people to just use the shortest way to what the want. Thats why I asked this question.

GertjanRoke started a new conversation Maybe Add A Default Markup For A New Discussion

Hello @JeffreyWay, I have made a account at the end of last year, because I got inspired to also help people out with there question on Laracasts, do to the post of @bobbybouwmann on Twitter about what a great people we got on Laracasts and how great it is to help out. I know it’s a long intro but stay with me, so if been doing so for the last days and I found it hard to notice on with version people are working. Some people tell it from the start and others don’t, so I thought why not give a bit of boilerplate to start with when you create a new discussion like you would when you make a issue on for the laravel framework repo.

My thoughts on how it should are as followed, when you select a “channel” you get some boilerplate in your “ask away” textarea and if you think you don’t need just remove it. By adding based on the channel you can write some custom boilerplate for every channel that maybe helps out by giving a better answer on the question of the discussion.

I would like to ask everyone to note there opinion or opinions on this question and maybe if it is a good idea you could make a video above it.

Already many thanks for reading this

GertjanRoke left a reply on Socialite Auth Issue - But Only For Google And Only For The First Time A User Attempts Logging In

@sheldonscott got a hard time following, I interpretation was that your build a callback method for Google auth and there you will sign in the user that you just created.

public function handleGoogleCallback()
{
    $_user = Socialite::driver('google')->user();

    ...

    $user = User::createGoogleUser($_user);

    auth()->login($user);

    return redirect()->route('home');
}

GertjanRoke left a reply on Function Not Defined

@tykus good point! looked over that one.

GertjanRoke left a reply on Error In Laravel But No Error In Phpmtadmin

@Skizo it looks like you just need te remove the jobs. from your groupBy method.

@shez1983 what’s the problem with showing a bit of code to see what’s wrong?

02 Jan
1 year ago

GertjanRoke left a reply on Function Not Defined

in your routes: Route::put('habits/add-point', '[email protected] '); and within your form action

GertjanRoke left a reply on [Package Development] Why Is Post Route In A Package Thrown An Exception Without A Message?

@yu0307 Could you copy some lines of the error that you get?

I also checked your controller because of your last reply and maybe Laravel don't likes that you return a array, so I fixed it a bit to a more Laravel way.

public function postLogin(Request $request)
    {
        $credentials  = $request->only(['email', 'password']);
        if (Auth::attempt($credentials, $request->has('remember')) {
            User::where('email', $request->email)->update(['Last_Login' => date('Y-m-d H:i:s')]);
            
            return response()->json(['status'=>'success', 'message'=>'Successfully Logged in', 'redirect'=>$this->redirectTo]);
        }else{
             return response()->json(['status'=>'error', 'message'=>'Login Failed<br/>Please check your credential and try again.']);
        }
    }

GertjanRoke left a reply on Filter Users In M:N Database

@Rymercyble you can just chain the whereHas method with different relation names like so:

User::whereHas('language_known', function($query) {  
    $query->where('language', 'php');  
})->whereHas('language_unknown', function($query) {  
    $query->where('language', 'javascript');  
})->get()

GertjanRoke left a reply on Filter Users In M:N Database

Oh sorry, I will update my reply

GertjanRoke left a reply on Function Not Defined

Oh sorry but you need to change your url to something like habit/{id}/add-point

GertjanRoke left a reply on Filter Users In M:N Database

Well in that case you could do something like:

User::whereHas(['country_relation_name' => function($query) {  
    $query->where('country', 'usa');  
}])->where('age', 20)->get();

For more information I will recommend the (documentation)[https://laravel.com/docs/5.5/eloquent-relationships#querying-relationship-existence]

GertjanRoke left a reply on Why Should I Create Symbolic Link In Laravel

You could do that but it is not meant for that.

But to answer your question, Laravel will only allow visitors in there public folder if you set your hosting correctly, and by making a symbolic link they can access the public folder within your storage/app/ and just view it directly without the use of a method within Laravel.

GertjanRoke left a reply on Function Not Defined

@RadoszSzymon your doing User::find($id) but I think it needs to be Habit::find($id).

GertjanRoke left a reply on Why Should I Create Symbolic Link In Laravel

If you want to show a file from your storage folder you can’t do so with only a url reference, thats why you need it. But for downloading it’s not needed

GertjanRoke left a reply on Filter Users In M:N Database

So you want a collection of users that have a age 20 and come from America?