Skip to content

Commit

Permalink
Pass test observers with new record
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinJun committed Jun 20, 2024
1 parent 39435bc commit 0be8c8a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
49 changes: 49 additions & 0 deletions app/Observers/ProjectObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\Observers;

use App\Models\Project;
use App\Models\Stat;

class ProjectObserver
{
/**
* Handle the Project "created" event.
*/
public function created(Project $project): void
{
Stat::query()->increment('projects_count');
}

/**
* Handle the Project "updated" event.
*/
public function updated(Project $project): void
{
//
}

/**
* Handle the Project "deleted" event.
*/
public function deleted(Project $project): void
{
//
}

/**
* Handle the Project "restored" event.
*/
public function restored(Project $project): void
{
//
}

/**
* Handle the Project "force deleted" event.
*/
public function forceDeleted(Project $project): void
{
//
}
}
6 changes: 4 additions & 2 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Providers;

use App\Models\Project;
use App\Observers\ProjectObserver;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -23,6 +25,6 @@ public function register()
*/
public function boot()
{
//
Project::observe(ProjectObserver::class);
}
}
}

0 comments on commit 0be8c8a

Please sign in to comment.