Moe

Moe

Member Since 5 Years Ago

Experience Points
26,450
Total
Experience

3,550 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
370
Lessons
Completed
Best Reply Awards
6
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.

Level 6
26,450 XP
Oct
09
1 month ago
Activity icon

Replied to Eloquent Update Not Working

Thanks to @munazzil I added an 'id' to my activities table and that solved the problem.

Thank you all!

Activity icon

Replied to Eloquent Update Not Working

This code is based on the demo off @Jeffrey in the video https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/27

<?php

namespace App\Traits;

use App\Activity;

trait RecordsActivity
{
    protected static function bootRecordsActivity ()
    {
        if (auth()->guest()) return;

        foreach (static::getRecordableEvents() as $event) {
            static::$event(function ($model) use ($event) {
                $model->recordActivity($event);
            });
        }
    }

    protected static function getRecordableEvents ()
    {
        return ['created'];
    }

    public function activity ()
    {
        return $this->morphMany(Activity::class, 'subject');
    }

    protected function recordActivity ($event)
    {
        $this->activity()->create([
            'user_id' => auth()->id(),
            'type' => $this->getActivityType($event),
        ]);
    }

    protected function getActivityType ($event)
    {
        return strtolower($event . '_' . (new \ReflectionClass($this))->getShortName());
    }
}

The code is working, but just not in the unit test.

Oct
08
1 month ago
Activity icon

Replied to Eloquent Update Not Working

PHPUnit 7.5.16 MySQL 5.7.24 Laravel 5.8

This all can be updated if needed!

Activity icon

Replied to Eloquent Update Not Working

Sorry the keys function returns just one key. The 2 records are below that one key.

Oct
07
1 month ago
Activity icon

Replied to Eloquent Update Not Working

The count returns 2 as expected.

And feed keys also returns the 2 records, but the created date of the first one isn't changed.

The code works on the app, but not in test.

Oct
06
1 month ago
Activity icon

Replied to Eloquent Update Not Working

It's a polymorphic relationship. Don't know if that make some difference.

Activity icon

Replied to Eloquent Update Not Working

same

        <server name="APP_ENV" value="testing"/>
        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>
Activity icon

Replied to Eloquent Update Not Working

You can find the feed method above.

Illuminate\Support\Collection^ {#1192
  #items: array:1 [
    0 => "2019-10-06"
  ]
}
Activity icon

Replied to Eloquent Update Not Working

Doesn't work.

dd($user->activities)

results

#attributes: array:6 [
        "user_id" => "1"
        "type" => "created_ticket"
        "subject_id" => "1"
        "subject_type" => "App\Ticket"
        "created_at" => "2019-09-29 12:28:13"
        "updated_at" => "2019-10-06 12:28:13"
      ]
      #original: array:6 [
        "user_id" => "1"
        "type" => "created_ticket"
        "subject_id" => "1"
        "subject_type" => "App\Ticket"
        "created_at" => "2019-09-29 12:28:13"
        "updated_at" => "2019-10-06 12:28:13"
      ]
      #changes: array:1 [
        "created_at" => "2019-09-29 12:28:13"
      ]

whit the fresh method

dd($user->fresh()->activities);

results

#attributes: array:6 [
        "user_id" => "1"
        "type" => "created_ticket"
        "subject_id" => "1"
        "subject_type" => "App\Ticket"
        "created_at" => "2019-10-06 12:29:32"
        "updated_at" => "2019-10-06 12:29:32"
      ]
      #original: array:6 [
        "user_id" => "1"
        "type" => "created_ticket"
        "subject_id" => "1"
        "subject_type" => "App\Ticket"
        "created_at" => "2019-10-06 12:29:32"
        "updated_at" => "2019-10-06 12:29:32"
      ]
      #changes: []

When i run the feed method on the activity class, i get the results like when i "fresh" my model. (Updates gone)

Oct
05
1 month ago
Activity icon

Replied to Eloquent Update Not Working

The update is also gone!

Oct
04
1 month ago
Activity icon

Started a new Conversation Eloquent Update Not Working

For one of my tests i try to update the created_at timestamp.

But this update will be completely ignored. I don't know why.

The test

public function it_fetches_a_feed_for_any_user ()
    {
        $user = $this->signIn();

        factory(Ticket::class, 2)->create(['user_id' => $user->id]);

        $user->activities->first()->update(['created_at' => Carbon::now()->subWeek()]);

        $feed = Activity::feed($user);

        $this->assertTrue($feed->keys()->contains(Carbon::now()->format('Y-m-d')));

        $this->assertTrue($feed->keys()->contains(Carbon::now()->subWeek()->format('Y-m-d')));
    }
    

The feed function at my Activity class

public static function feed (User $user, $number_of_activities = 25)
    {
        return static::where('user_id', $user->id)
            ->latest()
            ->with('subject')
            ->take($number_of_activities)
            ->get()
            ->groupBy(function ($activity) {
                return $activity->created_at->format('Y-m-d');
            });
    }

This is also one of my settings in the Activity class

protected $guarded = [];

When i dump and die the activities I see the next result

dd($user->activities)

...
#original: array:6 [
    "user_id" => "1"
    "type" => "created_ticket"
    "subject_id" => "1"
    "subject_type" => "App\Ticket"
    "created_at" => "2019-09-27 13:06:00"
    "updated_at" => "2019-10-04 13:06:00"
  ]
  #changes: array:1 [
    "created_at" => "2019-09-27 13:06:00"
  ]
...

But when I dump and die the actual feed, this is completely gone.

What am I missing?

Sep
12
2 months ago
Activity icon

Replied to Js History.pushState

It look like a caching problem.

fixed it by making a second route pointing to the same controller.

Route::get('/tickets', '[email protected]')->name('ticket.index');
Route::get('/api/tickets', '[email protected]')->name('api.ticket.index');
Activity icon

Started a new Conversation Js History.pushState

I'm building a filter for an overview of tickets, these tickets are loaded with ajax. When I check some boxes in the filter menu, I will change the URL without reloading.

history.pushState(null,null,this.uri);

This is no problem! But after that when i show a ticket and return to the overview page, i get an ajax response and not the regular page.

This is my index function on my controller:

public function index(TicketFilters $filters)
    {
        $tickets = Ticket::filter($filters)->get();

        if (request()->expectsJson()) {
            return $tickets;
        }

    .....

        return view('tickets.index', compact('tickets', 'channels', 'statuses'));
    }

What's the problem?

Aug
27
2 months ago
Activity icon

Replied to Foreign Key Error

How can it be that simple!

Activity icon

Started a new Conversation Foreign Key Error

Keep getting an error, and I don't see what's wrong.

code:

Schema::create('channels', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('parent_id')->unsigned()->nullable();
            $table->string('name');
            $table->timestamps();
});

Schema::table('channels', function (Blueprint $table) {
            $table->foreign('parent_id')->references('id')->on('channels');
});

error:

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `channels` add constraint `channels_parent_id_foreign` foreign key (`parent_id`) references `channels` (`id`))
Aug
15
2 months ago
Activity icon

Replied to Email Host

Nice, they have recently added this functionality

Activity icon

Replied to Email Host

I also need a mailbox

Activity icon

Started a new Conversation Email Host

Hi,

I'm using digital ocean to host my websites. But i'm still searching for a good e-mail host platform. Which one do you use?

Grtz!

May
30
5 months ago
Activity icon

Replied to Component Props And Url

@EDOC - Thanks!

Activity icon

Replied to Component Props And Url

as in the error above it returns http://site.test/post

Activity icon

Replied to Component Props And Url

@MAVERICKCHAN - The problem is in de URL string. It looks like the special chars are not allowed.

Activity icon

Replied to Component Props And Url

@MAVERICKCHAN - It's just as example. There is a closing tag!

Activity icon

Started a new Conversation Component Props And Url

Is there a way to pass an URL as parameter for a vue component?

<edit-post-modal :categories="{{ $categories }}" :post="{{ $post }}" :actionPath="{{ route('post.store') }}">

results in error

invalid expression: Unexpected token : in
http://site.test/post

  Raw expression: :actionpath="http://site.test/post"