Sending the full page entity to the PageWasUpdated event

parent 466daf82
......@@ -2,6 +2,8 @@
namespace Modules\Page\Events;
use Modules\Page\Entities\Page;
class PageWasUpdated
{
/**
......@@ -9,13 +11,13 @@ class PageWasUpdated
*/
public $data;
/**
* @var int
* @var Page
*/
public $pageId;
public $page;
public function __construct($pageId, array $data)
public function __construct(Page $page, array $data)
{
$this->data = $data;
$this->pageId = $pageId;
$this->page = $page;
}
}
......@@ -81,7 +81,7 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
event($event = new PageIsUpdating($model, $data));
$model->update($event->getAttributes());
event(new PageWasUpdated($model->id, $data));
event(new PageWasUpdated($model, $data));
$model->setTags(array_get($data, 'tags', []));
......
......@@ -162,7 +162,7 @@ class EloquentPageRepositoryTest extends BasePageTest
$this->page->update($page, ['en' => ['title' => 'Better!']]);
Event::assertDispatched(PageWasUpdated::class, function ($e) use ($page) {
return $e->pageId === $page->id;
return $e->page->id === $page->id;
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment