Skip to content

Commit

Permalink
Merge pull request #1716 from bakaphp/feat-message-workflow
Browse files Browse the repository at this point in the history
refact: when they seng strigify message
  • Loading branch information
kaioken authored Jul 21, 2024
2 parents eadd08a + 97fc46d commit 4807ce1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
use Kanvas\Inventory\Warehouses\Observers\WarehouseObserver;
use Kanvas\Notifications\Events\PushNotificationsEvent;
use Kanvas\Notifications\Listeners\NotificationsListener;
use Kanvas\Social\Messages\Models\Message;
use Kanvas\Social\Messages\Models\UserMessage;
use Kanvas\Social\Messages\Models\UserMessageActivity;
use Kanvas\Social\Messages\Observers\MessageObserver;
use Kanvas\Social\Messages\Observers\UserMessageActivityObserver;
use Kanvas\Social\Messages\Observers\UserMessageObserver;
use Kanvas\Social\UsersLists\Models\UserList;
Expand Down Expand Up @@ -73,6 +75,7 @@ public function boot()
UserList::observe(UsersListsObserver::class);
Lead::observe(LeadObserver::class);
UserMessage::observe(UserMessageObserver::class);
Message::observe(MessageObserver::class);
Warehouses::observe(WarehouseObserver::class);
Regions::observe(RegionObserver::class);
Status::observe(StatusObserver::class);
Expand Down
2 changes: 2 additions & 0 deletions src/Domains/Social/Messages/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Kanvas\Social\Topics\Models\Topic;
use Kanvas\Users\Models\UserFullTableName;
use Kanvas\Users\Models\Users;
use Kanvas\Workflow\Traits\CanUseWorkflow;
use Laravel\Scout\Searchable;
use Nevadskiy\Tree\AsTree;

Expand Down Expand Up @@ -55,6 +56,7 @@ class Message extends BaseModel
use SoftDeletesTrait;
use HasPermissions;
use AsTree;
use CanUseWorkflow;

protected $table = 'messages';

Expand Down
21 changes: 21 additions & 0 deletions src/Domains/Social/Messages/Observers/MessageObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Kanvas\Social\Messages\Observers;

use Kanvas\Social\Messages\Models\Message;
use Kanvas\Workflow\Enums\WorkflowEnum;

class MessageObserver
{
public function created(Message $message): void
{
$message->fireWorkflow(WorkflowEnum::CREATED->value, true, ['app' => $message->app]);
}

public function updated(Message $message): void
{
$message->fireWorkflow(WorkflowEnum::UPDATED->value, true, ['app' => $message->app]);
}
}

0 comments on commit 4807ce1

Please sign in to comment.