Perdanjam

Member Since 1 Year Ago

Experience Points
34,990
Total
Experience

10 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
301
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

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

  • Community Pillar

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

Level 7
34,990 XP
Apr
27
1 week ago
Activity icon

Started a new Conversation Vapor Uploads Can't Pass Optional ?User To Gate, Bug Or Intentional?

The /vapor/signed-storage-url for file uploads in Vapor core authorizes like so:

// Laravel\Vapor\Http\Controllers\SignedStorageUrlController.php

Gate::authorize('uploadFiles', [
            $request->user(),
            $bucket = $request->input('bucket') ?: $_ENV['AWS_BUCKET'],
        ]);

When unauthenticated (guest) calls this, it will always fail before getting to the UserPolicy. So you can't pass ?User to the uploadFiles() method.

I am curious if this is a bug or intentional? I guess allowing guests access to a file upload end point is bad practice, so maybe it's intentional??

Apr
23
2 weeks ago
Activity icon

Replied to How To Return A Specific HasMany Collection Depending On Which One Has Items?

It looks like there is not a specific relation for this, discussed here https://github.com/laravel/ideas/issues/1867

I think I'll use a manyToMany and just get the right collection based on which one isn't empty.

Activity icon

Started a new Conversation How To Return A Specific HasMany Collection Depending On Which One Has Items?

I have a model Stage, and I want to return a collection of either Foo Bar or Baz depending on which of those collections has items in it. Only one will ever have items.

I looked at Polymorphic oneToMany but it looks like I'd have to call $stage->foos,$stage->bars , or$stage->bazes, to get the collection.

I want to call $stage->details and return the correct collection.

Is there a relation for this or do I need to use the above polymorphic relation and create a custom $stage->details() method?

Apr
21
2 weeks ago
Activity icon

Started a new Conversation Weird Reactivity In Vue 3 And Typescript, Array.splice() Resetting Internal Object Boolean

Below is a simplified version of my component. newCards array always has one object with selected: true, the others have selected: false.

Problem: removeCard(x) is changing the selected: true card to the previous card. Eg after removeCard(2), card[1].selected becomes true. After removeCard(0), all cards selected = false.

In my actual component, I use selectedCardIndex to track/control the selected: true card, but removeCard() still resets the selected: true card to the previous card, even though selectedCardIndex is correct. Eg selectedCardIndex.value = 1, but card at index 0 is the only one with selected: true.

interface NewCard {
    word: string,
    selected: boolean,
    promptType?: PromptType,
}

<script lang="ts">
export defineComponent({
  setup() {
    let newCards: Array<NewCard> = reactive([]);
    let selectedCardIndex = ref(0);

    function removeCard(i: number) {
      newCards.splice(i, 1);
    }

    return {
      removeCard,
      selectedCardIndex,
    };
  },
});
</script>
Mar
27
1 month ago
Activity icon

Started a new Conversation Keep Focus State On Input - Inertia.js

I've got a search filter function very similar to PingCRM, with a watch function making a get request to the current route to filter the results. The only real difference between my app and PingCRM is that I'm using Inertia.get instead of Inertia.replace , as advised in the docs.

But when the results load, the input loses focus. So, I pass preserveState: true to the options on Inertia.get. The input remains focussed now, but the results of thequery filter don't update. I've solved this by watching the prop and updating the data manually in the watch function.

But Jonathan's code doesn't do this last bit and input remains focussed when the results load. I can't figure out why... Can anyone advise what might be missing?

I've tried autofocus, but it doesn't work. The only other difference is that I'm not using his query string package to remove the query string.

If you've not looked at PingCRM then this video explains the query filter I'm referencing about halfway through https://laracasts.com/series/learn-inertia-with-jeffrey/episodes/10

Feb
27
2 months ago
Activity icon

Replied to Installing Vue Through Laravel Mix Is Hard

Mix is a wrapper around Webpack. Its main purpose is to bundle code that you already have (usually this means making a single browser-friendly app.js file from many different .js/.vue /.whatever files).

In your case, Vue wasn't installed, so the .vue() method in Mix caused an error.

Feb
26
2 months ago
Activity icon

Replied to Installing Vue Through Laravel Mix Is Hard

@warpig I think you may have installed Vue in a different folder..? It's not in your package.json devDependencies. Have a look to see if you have a node_modules somewhere other than your root directory.

Delete that and navigate to your route use cd .. to go up a level in your terminal and reinstall vue

Activity icon

Replied to Installing Vue Through Laravel Mix Is Hard

Man I hate config and am no expert but the only thing I can think is you might have one of either:

an incompatible version of node

an incompatible combination of Vue and Mix (eg, I'm not 100% sure if Vue 3 works with Mix).

You might get more help if you post your package.json and composer.json

Feb
25
2 months ago
Activity icon

Replied to Spark Paddle Trial Explanation

After some source-diving and tweet-diving, it's clear that Spark does not support trials with Paddle at the time of writing.

"While on trial via Paddle, a user cannot make any changes to the subscription (change plans or update quantity). Once Paddle fixes that, we'll be able to support it on Spark."

Feb
24
2 months ago
Activity icon

Awarded Best Reply on Laravel + Inertia How To Create "Back" Link

Add the back method in Vue

  methods: {
    back() {
      window.history.back();
    },
  }

and use an anchor tag:

<a href="#" @click="back">Back</a>
Activity icon

Replied to Laravel + Inertia How To Create "Back" Link

Add the back method in Vue

  methods: {
    back() {
      window.history.back();
    },
  }

and use an anchor tag:

<a href="#" @click="back">Back</a>
Activity icon

Started a new Conversation Spark Paddle Trial Explanation

In the Spark Paddle docs, I'm a bit confused by the explanation around trial periods. I think it's trying to say that you can't do free trials with Paddle? But it's a bit verbose and I wasn't sure if they are trying to explain a way you CAN do a free trial period.

https://spark.laravel.com/docs/1.x/spark-paddle/plans.html#trial-periods

We can get card details up front by setting trail days to 0 in the Paddle dashboard. And use onTrial() in our app. However, the user is billed on day 1 with this set up, and there is no trial as far as Paddle is concerned.

Is there any way of getting card details up front and NOT billing (giving a trial period)?

Jan
11
3 months ago
Activity icon

Started a new Conversation Weird Inertia Behavior, Validation Errors Object Empty - Production Only

Possibly a Vapor issue.

I've got a form with a validation rule for one of the fields ['required', 'array', 'min:2']. When I submit an empty form, I get the errors object as expected.

But when I submit the form with the required array as length only 1 (not valid), I don't get any errors back. Not for any of the fields, neither the array min:2 field or any other fields.

screenshots

The weirdest part is that this is only happening in production (Laravel Vapor). It works fine locally and I get all my validation errors passed to inertia as you'd expect.

Can anyone suggest what might be happening here?

Jan
04
4 months ago
Activity icon

Started a new Conversation Add An SEO Friendly Blog To An InertiaJs Vapor Site

I'm trying to think of a nice way to add a blog to an Inertia site, where the blog isn't using inertia. I'd like to get a vue, laravel or markdown friendly CMS involved too if possible. Does anyone have any neat ideas?

One idea I have is to use a subdomain, blog.site.com, and have that whole thing in a subfolder with it's own vapor.yml, but this seems like it might be overkill, and has the drawback of needing its own environment...

Dec
10
5 months ago
Activity icon

Awarded Best Reply on Scout MakeAllSearchableUsing Not Importing Eager Loaded Relationship Models

In case anyone is reading this with the same problem. I couldn't actually find any documentation from Algolia on makeAllSearchableUsing().

So I just used the toSearchableArray() public method instead.

For reference my code looks like this now

public function toSearchableArray()
    {
        $array = $this->toArray();

        $array['sentences'] = $this->sentences->map(fn($sen) => $sen->transcript);

        return $array;
    }
Activity icon

Replied to Scout MakeAllSearchableUsing Not Importing Eager Loaded Relationship Models

In case anyone is reading this with the same problem. I couldn't actually find any documentation from Algolia on makeAllSearchableUsing().

So I just used the toSearchableArray() public method instead.

For reference my code looks like this now

public function toSearchableArray()
    {
        $array = $this->toArray();

        $array['sentences'] = $this->sentences->map(fn($sen) => $sen->transcript);

        return $array;
    }
Dec
08
5 months ago
Activity icon

Started a new Conversation Scout MakeAllSearchableUsing Not Importing Eager Loaded Relationship Models

As the title says. https://laravel.com/docs/8.x/scout#modifying-the-import-query

My index does not have contain the relationship when imported.

I'm a bit clueless on what extra information to provide to anyone who may be able to help.

The doc blocks for the makeAllSearchableUsing method show it returns a Builder instance, which is true, but it's a massive data dump when I dd() it inside makeAllSearchableUsing and run import.

Could anyone provide some pointers on where to look as to why this query isn't bringing the relationships with it?

     /**
     * Modify the query used to retrieve models when making all of the models searchable.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    protected function makeAllSearchableUsing($query)
    {
        return $query->with('user');
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

*edit: I am using the algolia driver