MarkyzZz

MarkyzZz

Member Since 1 Year Ago

Experience Points 8,930
Experience Level 2

1,070 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 88
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

15 Mar
5 days ago

MarkyzZz left a reply on Check If Polymorphic Relation Exists Returns Empty

@RICHARD - I was looking to store both notifications and notification histories in same table. Both of these have almost the same columns, except for the notification history that has one more column "status". I didn't want to create another table only because of one column difference. Apparently, by creating another table and storing the notification histories apart solves my problem in the way you mentioned. Thank you very much :))

MarkyzZz left a reply on Check If Polymorphic Relation Exists Returns Empty

@STAUDENMEIR - The problem with this approach is that the Notification will always have an emitter_id though the model with this emitter_id might not exist.

MarkyzZz started a new conversation Check If Polymorphic Relation Exists Returns Empty

Basically, i have model Notification that morphs to two other models (Company and Scooter), i called them "the emitter". The problem is that i cannot get the notification for the companies or scooters that exist. It always returns me empty collection. This is my code: Notification.php :

public function emitter()
{
    return $this->morphTo();
}

Scooter.php and Company.php:

public function notifications()
{
    return $this->morphMany(Notification::class, 'emitter');
}

migration:

Schema::create('notifications', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('emitter_id')->unsigned()->index()->nullable();
            $table->string('emitter_type')->nullable();
            $table->timestamps();
        });

And the queries i've tried:

$notification = Notification::has('emitter')->get(); // returns empty collection
$notification = Notification::whereHas('emitter', function($inner_query){ return $inner_query; })->get(); //same
12 Sep
6 months ago

MarkyzZz left a reply on Laravel Polymorphic Relationship On Same Table (different User Managers)

@Vilfago

public function managedByArea()
    {
        return $this->hasMany(User::class, 'area_manager_id');
    }

    public function area_manager()
    {
        return $this->belongsTo(User::class, 'area_manager_id');
    }

    public function managedByCountry()
    {
        return $this->hasMany(User::class, 'country_manager_id');
    }

    public function country_manager()
    {
        return $this->belongsTo(User::class, 'country_manager_id');
    }
    public function managedByFleet()
    {
        return $this->hasMany(User::class, 'fleet_manager_id');
    }

    public function fleet_manager()
    {
        return $this->belongsTo(User::class, 'fleet_manager_id');
    }

This is the solution i've come so far. Thanks for the reply! Saved myself alot of time and headaches :).

11 Sep
6 months ago

MarkyzZz started a new conversation Laravel Polymorphic Relationship On Same Table (different User Managers)

I have the users table, where each user can be assigned to a manager. I have 3 types of Managers (Country Manager, Area Manager and Fleet Manager). One Area manager can have many Fleet Manager and Country Manager, and one Country Manager can have many Fleet Manager. My users table have the columns fleet_manager_id, country_manager_id,area_manager_id that reference on id of users table. The question is that i don't know how to set a polymorphic relationship on same table. Migration:

Schema::table('users', function (Blueprint $table) {
    $table->integer('fleet_manager_id')->unsigned()->nullable();
    $table->foreign('fleet_manager_id')->references('id')->on('users');
    $table->integer('country_manager_id')->unsigned()->nullable();
    $table->foreign('country_manager_id')->references('id')->on('users');
    $table->integer('area_manager_id')->unsigned()->nullable();
    $table->foreign('area_manager_id')->references('id')->on('users');
});

My User Model:

public function fleetManagers()
{
    return $this->hasMany(User::class, 'fleet_manager_id');
}

public function countryManager()
{
    return $this->belongsTo(User::class, 'country_manager_id');
}

public function areaManager()
{
    return $this->belongsTo(User::class, 'area_manager_id');
}