jorisvanandel

jorisvanandel

Member Since 1 Year Ago

Experience Points 920
Experience Level 1

4,080 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 2
Lessons
Completed
Best Reply Awards 0
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.

31 Jul
1 month ago

jorisvanandel started a new conversation Flysystem GetSize Doesn't Work On Directory

I have a Digital Ocean space and I try to run getSize() on a directory but it returns false. When I run it on a file it does return the size.

Is there no way to get the size of a directory instead of a file?

10 Jul
2 months ago

jorisvanandel started a new conversation Failed To Parse Dotenv File Due To An Invalid Name.

Hi my server logs this error: Failed to parse dotenv file due to an invalid name.

The env file looks completely normal I don't understand why it's not parsing the .env file correctly. Any help?

22 Apr
4 months ago

jorisvanandel left a reply on Call To A Member Function AddEagerConstraints() On Integer With Scope Function

@STAUDENMEIR - The database of the model's relationship.

Imagine Post being the main model and Comment being the relationship. Comment has a 'likes' attributie and I'm trying to sum all the Comments' likes of a certain Post. (This is just a stupid example)

jorisvanandel started a new conversation Call To A Member Function AddEagerConstraints() On Integer With Scope Function

One of my models has a relationship with another model and I want to put the sum of one of it's values in a scope so I can call it conditionally.

Right now I have the following code.

public function scopeWithSum ($query)
{
    return $query->with('relationship')->sum('column');
}

It gives the error in the title. Amy help is appreciated.

19 Apr
5 months ago

jorisvanandel left a reply on Only Getting Accessor Values On Specific Queries

@JLRDW - Could you give me an example of this? I tried to put the same logic into a Scope but it gives me the following error:

Call to a member function addEagerConstraints() on integer
17 Apr
5 months ago

jorisvanandel left a reply on Only Getting Accessor Values On Specific Queries

@JLRDW - I haven't looked at scopes yet but that looks like a great solution. Thank you a lot!

jorisvanandel left a reply on Only Getting Accessor Values On Specific Queries

The reason I didn't post my model is because most of the code is irrelevant for this question. I'll give a simple example.

protected $appends = [
        'sum',
];

getSumAttribute() {
    $sum = 0;
    foreach ($model->relation as $relation) {
        $sum += $relation->value;
    }
    return $this->attributes['sum'] = $sum;
}

This 'sum' attribute is only required on some pages (and thus on some queries), but it gets called on every query and ends up in every query result.

jorisvanandel started a new conversation Only Getting Accessor Values On Specific Queries

Hi,

I got a few accessors defined in my Model that take some time (they sum certain values of a relationship). It's not that bad but I only want these accessors called conditionally (when I need those values).

It makes all my queries rather slow and I only need the accessor values on certain queries.

How can I conditionally call the accessors so they don't slow down queries they don't need to?

14 Feb
7 months ago

jorisvanandel left a reply on [ELOQUENT] Ordering Users By Last Name On 'name' Column

@CRONIX - Thanks I will try that.

But no you actually need 3 because (at least in my country) someone could be named Daniel van der Plas (and it should be filtered on Plas not on van der.

10 Feb
7 months ago

jorisvanandel left a reply on [ELOQUENT] Ordering Users By Last Name On 'name' Column

@CRONIX - Yes I've thought about doing that but that would require 3 columns in the database instead of 1.

How would you do the splitting that you were talking about? I'd like to try it anyways, the last word that starts with a capital letter is the word that should be sorted on in any case. Which should be do-able.

Thanks regardless.

jorisvanandel started a new conversation [ELOQUENT] Ordering Users By Last Name On 'name' Column

Hi,

I'm trying to order users on their last name instead of their surname, which is the default behavior.

What I have so far is this. I'm pretty sure I have to use a closure on the orderby method, I just don't know exactly how.

User::orderBy('name', 'asc')->get();

The following output:

Alexander Putin

George Bush

Should become:

George Bush

Alexander Putin

Thanks in advance.

05 Feb
7 months ago

jorisvanandel started a new conversation Forcing Rerender Of Vue Instance From Within Component

Hi,

My app has a template (App.vue) but I don't want the log in screen to be a different template (Login.vue)

So I figured I should use a closure on the render property like this:

    render: function (app) {
        if (authenticated) { // or whatever
            return app(App);
        } else {
            return app(Login);
        }
    }

So when a user logs in on the Login component, authenticated becomes true and it should render the components in the App.vue template and not the Login.vue template. It only works if I manually refresh the page.

Is there a way to call the Vue instance in my app.js from my Login component so I can manually rerender the vue instance so it renders with the proper template? Or is there a better way to go around this?

I really don't want to put a v-if="authenticated" and v-else in my App.vue template, I'm sure there is a better way.

Thank you in advance.

20 Jan
7 months ago

jorisvanandel started a new conversation Vue Router Active Link Only Showing On /users/ And Not On /users/show/1

Hi, as the title says the <router-link to="/users"></router-link> only has the active link class when it's on /users/ and when i push to /users/show/1 using:

            showRecord(id) {
                this.$router.push(`/users/show/${id}`)
            },

It goes to /users/show/1 but the <router-link> doesn't have the active class anymore.

Here is the code for the router-link:

<router-link to="/users" class="aw-menu-link">Users</router-link>

I'm not using the exact property by the way.

Thanks for any help in advance.

26 Nov
9 months ago

jorisvanandel started a new conversation (SOLVED) Can't Delete Files On Digital Ocean Space From Laravel Application

Hi,

I can upload files to my digital ocean running the following code:

Storage::disk('do_spaces')->putFileAs(
                $folder->slug . '/original', $file, $filename, 'public'
            );

However, when I try to delete it with the following code, it doesn't do anything.

Storage::disk('do_spaces')->delete($file->folder->slug . '/original/' . $file->name);

Anyone has any idea why this codeline doesn't delete the file? Thanks in advance.

08 Nov
10 months ago

jorisvanandel left a reply on Can't Use JavaScript Function Inside Vue Component

@CRONIX - hi, thanks for your answer. How do I import jQuery? I want to use this datatable function because I it's included in my template and I really like it.

jorisvanandel left a reply on Can't Use JavaScript Function Inside Vue Component

@SFZ0311 - Hi, thanks for your answer. I've imported the function like this

import mDatatable from '../assets/scripts.bundle.js';

Which should work I think. However, it gives the following error:

TypeError: (intermediate value)(intermediate value).block is not a function

I tried when having the routes as single words (/dashboard, /users, etc.). The datatables loaded, but when I added /admin in front of the routes in app.js, the datatables stopped loading.

The weird thing however is that I get this error in both cases.

07 Nov
10 months ago

jorisvanandel started a new conversation Can't Use JavaScript Function Inside Vue Component

Hi, I have a Vue component which has to call a function that is defined in a script outside the component.

Outside the component I can call it by doing something like this:

$('#m_datatable_users').mDatatable(options);

This works fine, but when I try to call this function in the mounted() of my Vue component, it gives the following error:

$(...).mDatatable is not a function

How can I call this function that is defined outside the component, inside the component?

04 Nov
10 months ago

jorisvanandel left a reply on Updating User Gives 404 Error

Thanks.

Yes I agree, that is what I used to have but now I want to give an admin access to updating other users, so that no longer works.

jorisvanandel started a new conversation Updating User Gives 404 Error

Hi I got a form that looks like this (fields are removed).

<form action="{{ route('users.update', Auth::user()->id) }}" method="POST">
                    {{ csrf_field() }}
                    {{ method_field('PATCH') }}
</form>

And a route that looks like this:

Route::patch('/users/{$id}', '[email protected]')->name('users.update');

However, when I submit the form, I get a 404 error. Even though the controller method called update is suposed to return the request.

What am I missing?

05 Aug
1 year ago

jorisvanandel left a reply on How To Pass A $request Variable Into The Validate Method?

@tykus I defined $this->order_id as $request->order_id. It seems to work now, must've made some spell error. Thanks anyways!

jorisvanandel started a new conversation How To Pass A $request Variable Into The Validate Method?

Hi,

I've created a custom Rule but it's not letting me pass one of the $request parameters into the validate method.

Here is the code:

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

    $this->order_id = $request->order_id;
        $request->validate( [
            'price' => [
                'required', new BidIsLowEnough($this->order_id),
            ],
        ]);
    }

If I replace $this->order_id with an integer as a parameter for BidIsLowEnough everything works fine.

Thanks in advance.

31 Jul
1 year ago

jorisvanandel left a reply on Loop Through Eloquent Object In Controller

@crnkovic Thank you. And how can I use that on a collection?

If I do this

WatchResource::collection(Watch::all()->toArray())

I get the following error:

Call to a member function first() on array
30 Jul
1 year ago

jorisvanandel started a new conversation Loop Through Eloquent Object In Controller

I want to loop through the attributes of this watch but it doesn't give me the desired output.

$watch = Watch::find(1);
foreach ($watch as $property => $value) {
    $properties[$property] = $value;
}
return $properties;

This is the output I get:

{
incrementing: true,
exists: true,
wasRecentlyCreated: false,
timestamps: true
}

But I want all the attributes of the watch stored in the properties variable. Is there anything I'm missing? A desired output would be something like this:

{
id: 1,
price: 2399.99,
....
}