catalin8

catalin8

Member Since 6 Months Ago

Experience Points
12,270
Total
Experience

2,730 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
119
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 3
12,270 XP
May
25
1 day ago
Activity icon

Replied to Update Query Throws "SQLSTATE[HY093]: Invalid Parameter Number" Error. Parameters Don't Get Passed On

Ok, this thing is so weird I have zero explanation for it, but here's the solution:

  1. First of all you need to explicitly update updated_at yourself, because otherwise Laravel would try and do it itself and make a big mess out of everything.

  2. For some unknown reason the initial setup simply failed to assign the variables to the placeholder ?: DB::raw("REPLACE(hierarchy, ?, ?)", [$old_hierarchy, $new_hierarchy])

  3. I had to do it using setBindings, but on top of that couldn't assign all of them through this method because they would have gotten messed up once again, so only did it for the DB::raw statements.

Category::setBindings([$old_hierarchy, $new_hierarchy, now()])
    ->whereRaw("hierarchy LIKE ?", [$old_hierarchy . '>%'])
    ->update([
        'hierarchy' => DB::raw("REPLACE(hierarchy, ?, ?)"),
        'updated_at' => DB::raw("?")
    ]);

If anyone has any explanation of this whole crazy thing, please let me know

Activity icon

Started a new Conversation Update Query Throws "SQLSTATE[HY093]: Invalid Parameter Number" Error. Parameters Don't Get Passed On

I have this rather simple query:

Category::whereRaw('hierarchy LIKE ?', [$old_hierarchy . '>%'])
    ->update([
        'hierarchy' => DB::raw("REPLACE(hierarchy, ?, ?)", [$old_hierarchy, $new_hierarchy])
    ]);

And it keeps giving me this error:

SQLSTATE[HY093]: Invalid parameter number (SQL: update `categories` set `hierarchy` = REPLACE(hierarchy, 2020-05-25 22:30:55, first_param>%), `categories`.`updated_at` = ? where hierarchy LIKE ?)

Seems like no parameters are passed to the DB::raw. Any idea what's going on ?

May
23
3 days ago
Activity icon

Started a new Conversation Return Additional Values To The Controller In The Form Request. Is This Good Practice ?

I have a Category model and need to store new categories by receiving the category hierarchy from input as a string.

And I want to only add the categories that already have a parent, but at the same time return the parent_id to the controller in the validation (in case it exists), so only one database request is performed, instead of 2 (one in validation and another one to get the parent_id).

Is it good practice to build a Form Request that performs this validation and which passes the parent_id to the controller by adding it to the returned array ? Or is there a better way to achieve this ?

May
22
4 days ago
Activity icon

Replied to What Would Be The Best Way To Handle A Model Column That Is Derived From Another One

Thanks! It's only that I needed a setter, so I ended up doing it like this:

use Illuminate\Support\Str;

class SomeModel extends Model
{
    public function setNormalizedTitleAttribute($value)
    { 
        $this->attributes['title'] = $value;
	$this->attributes['normalized_title'] = Str::slug($value);
    }
}
Activity icon

Started a new Conversation What Would Be The Best Way To Handle A Model Column That Is Derived From Another One

On a particular model I have a

title ( text ) column and another

normalized_title a sort of slug derived from the title column

Being fairly new to Laravel and seeing how most of the learning tutorials are straight forward and super clean I wanted to ask if there is any particular way to handle such a column in a "automated" way.

On one hand I was thinking to set up an observer and simply modify the normalized_title whenever the title column is updated or created.

But this would probably cost at least an extra update operation, and that's not what I'm looking for.

So, is there any way to achieve this ?

Thank you!