Sky7ure

Sky7ure

Member Since 1 Year Ago

Experience Points
34,390
Total
Experience

610 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
306
Lessons
Completed
Best Reply Awards
0
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.

Level 7
34,390 XP
Feb
18
3 months ago
Activity icon

Awarded Best Reply on Format Nova Field Input Before Validation

I had to abandon the Field's validation with ->rules() and use ->fillUsing() method as follows:

->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
    if ($request->exists($requestAttribute)) {
        // apply the slug format
        $value = Str::slug($request[$requestAttribute]);
        $request[$requestAttribute] = $value;

        if ($request->method() === 'POST') {
            // validate a new record (POST)
            $request->validate([
                $requestAttribute => 'required_if:is_article,1|unique:newsfeeds,slug',
            ]);
        } elseif ($request->method() === 'PUT') {
            // validate an updated record (PUT)
            $request->validate([
                $requestAttribute => 'required_if:is_article,1|unique:newsfeeds,slug,'.$model->id,
            ]);
        }

        // upon a validation pass
        $model->{$attribute} = $value;
    }
})
Activity icon

Replied to Format Nova Field Input Before Validation

I had to abandon the Field's validation with ->rules() and use ->fillUsing() method as follows:

->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
    if ($request->exists($requestAttribute)) {
        // apply the slug format
        $value = Str::slug($request[$requestAttribute]);
        $request[$requestAttribute] = $value;

        if ($request->method() === 'POST') {
            // validate a new record (POST)
            $request->validate([
                $requestAttribute => 'required_if:is_article,1|unique:newsfeeds,slug',
            ]);
        } elseif ($request->method() === 'PUT') {
            // validate an updated record (PUT)
            $request->validate([
                $requestAttribute => 'required_if:is_article,1|unique:newsfeeds,slug,'.$model->id,
            ]);
        }

        // upon a validation pass
        $model->{$attribute} = $value;
    }
})
Activity icon

Replied to Format Nova Field Input Before Validation

I have a description attribute that could be used as a slug and the rest are Translatable stuff. I don't want Admins to have to input that in a slug format, so I AM using a mutator to setDescriptionAttribute() in slug format in the database.

The issue is that validation of the Nova Field beforehand isn't recognizing this mutator to check for a unique rule and stop duplicating records from reaching the database.

Is there any way to format the Nova Text Field input to be used for validation?

Activity icon

Started a new Conversation Format Nova Field Input Before Validation

I have an attribute slug that is both nullable and unique. Validation in Nova doesn't seem to hold place using: ->rules('required_if:is_article,1', 'unique:newsfeeds,slug')

I'm getting a constraint violation (duplicate entry), so the validation isn't working, I guess! Are the rules used correct?

P.S. Since it's a slug, I'm using ->resolveUsing(function ($slug) { return Str::slug($slug); }) too; or should I?

P.P.S. How can I override the Nova field entry (input) exactly?

P.P.P.S. I'm using a mutator to set the attribute to be Str::slug()ed, but it's not helping still...

Feb
16
3 months ago
Dec
20
5 months ago
Activity icon

Started a new Conversation Condition A Nova Theme

How to apply a theme under a certain condition? I have an RTL theme that I want to apply if the App::getLocale() let's say was ar for example.

Activity icon

Started a new Conversation Importing Different Bootstrap (RTL) Based On The App Locale

Greetings,

How can I import the normal bootstrap.scss as well as another bootstrap-rtl.scss based on the Session's app.locale value or the App::getLocale() value. I would imagine it done somewhere in app.scss, but I have no idea how to reach locale in there.

Can someone elaborate on the best way to load Bootstrap based on a condition related to the application locale, please?

Dec
19
5 months ago
Activity icon

Started a new Conversation Get Post Tags Count In Nova

https://laracasts.com/series/laravel-nova-mastery/episodes/9

I'm confused why the lecturer said that he got the tags count "from the database!" or something of the sort! Because I thought the best way is to use the tags() relationship on Post and count() that accordingly!

But I don't know how it's exactly done in Nova.

Activity icon

Commented on Filters And Lenses

Where did you store the amount of Tags associated with a Post exactly? You mentioned it was in the database! But is it really a good practice, since you'd have to update that count on each time a Tag is associated with a Post?!

Can you please elaborate on this part, whether to save a Tags count on the Post model, what would the right way be, and how to do it?

Because I thought the best way was to use the Tags relationship with a Post, and count() that accordingly... But I don't know how it's exactly done in Nova.

Dec
05
5 months ago
Activity icon

Replied to Why Doesn't Documentation Include $request->get() Method?

Understood, my bad.

Can you explain though the usage of the two relationships in a route or an API controller action, please? My mind is frozen now and I cannot see how these resource::collection()s are supposed to work in this manner! And why can only one of the two actually take place - according to the author's comments?

Activity icon

Started a new Conversation Why Doesn't Documentation Include $request->get() Method?

In Laravel Up and Running (2nd Edition) book, the following example was given and...

1- I'm confused about the usage of $request->get() instead of $request->input(). Why isn't the documentation even mentioning it?

2- I'm wondering if it's possible for the model to be eager-loaded AND the URL still "ask for it" all in the same time? -Like the two conditions coming true and 'bones' being transformed twice! If that happens, would it be even bad? Wouldn't the example be more useful with an if-else statement instead? Or... is the second 'bones' referencing the first 'bones' by any means? /@[email protected]"

// in app/Http/Resources/DogCollection.php
public function toArray()
{
    return [
        'name' => $this->name,
        'breed' => $this->breed,
        // load relationship if it's eager-loaded
        'bones' => BoneResource::collection($this->whenLoaded('bones')),
        // load relationship if url asks for it
        'bones' => $this->when(
            $request->get('include') == 'bones',
            BoneResource::collection($this->bones)
        ),
    ];
}
Nov
24
6 months ago
Activity icon

Replied to Any Alternatives To WhereRaw() Query-builder Method?

That makes a lot of sense now! Thank you ever so kindly, Sir Nakov! :D

Activity icon

Replied to Any Alternatives To WhereRaw() Query-builder Method?

So true, Sir @nakov... But I'm trying to learn the query-builder from Laravel Up and Running book, and Sir Matt mentioned that using whereRaw() must be done with extreme caution, so to speak... And then he proceeds to provide the example for whereExists() and use whereRaw() in it anyways! So I was confused and thinking that this might be the only way to make a whereExists() query work or useful, in other words, and wondered if there is any other way to work around it!

That's why I'm asking, so what do you think? Yet thank you kindly, Sir, for your answer nevertheless!^_^

Activity icon

Started a new Conversation Any Alternatives To WhereRaw() Query-builder Method?

Is there an alternative way to using whereRaw() method - since it's insecure (not escaped)? Or is using it in this scenario something that is simply inevitable?! Or should I not be that terrified of using it anyways?

$commentators = DB::table('users')
    ->whereExists(function ($query) {
        $query->select('id')
            ->from('comments')
            ->whereRaw('comments.user_id = users.id');
    })->get();