final commit on this pr: added trick in CategoryObserver to make it unit testable (unit tests not included)
This commit is contained in:
parent
ebcae41f3c
commit
8f010045e7
|
|
@ -4,6 +4,7 @@ namespace Webkul\Category\Observers;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Webkul\Category\Models\Category;
|
use Webkul\Category\Models\Category;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class CategoryObserver
|
class CategoryObserver
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +27,11 @@ class CategoryObserver
|
||||||
public function saved($category)
|
public function saved($category)
|
||||||
{
|
{
|
||||||
foreach($category->children as $child) {
|
foreach($category->children as $child) {
|
||||||
$child->touch();
|
// Hacky trick to make this method unit-testable (instead of $child->touch()
|
||||||
|
// as the unit test is too fast)
|
||||||
|
$child->setUpdatedAt(Carbon::now()->addSecond());
|
||||||
|
|
||||||
|
$child->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue