Skip to content

Commit

Permalink
Merge pull request #418 from bakaphp/boards
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Jun 21, 2023
2 parents 1a6ed3b + 2b97ccc commit a77d916
Show file tree
Hide file tree
Showing 19 changed files with 777 additions and 76 deletions.
27 changes: 27 additions & 0 deletions app/GraphQL/Social/Builders/UsersLists/SearchBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Social\Builders\UsersLists;

use Illuminate\Database\Eloquent\Builder;
use Kanvas\Apps\Models\Apps;
use Kanvas\Social\UsersLists\Models\UserList as ModelUserList;
use Laravel\Scout\Builder as ScoutBuilder;

class SearchBuilder
{
/**
* Build the search query.
*
* @param string $search
*/
public function search(mixed $builder, mixed $req): Builder|ScoutBuilder
{
$search = ModelUserList::search($req['search'])
->where('is_public', $req['is_public'] ?? true)
->where('apps_id', app(Apps::class)->id);

return $search;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function create(mixed $root, array $request)
$message = $action->execute();
$activity = [];

/* $activityType = UserMessageActivityType::where('name', 'follow')->firstOrFail();
$activity = [
$activityType = UserMessageActivityType::where('name', 'follow')->firstOrFail();
$activity = [
'username' => '',
'entity_namespace' => '',
'text' => ' ',
'type' => $activityType->id,
]; */
];

FillUserMessage::dispatch($message, $message->user, $activity)->onQueue('message');

Expand Down
70 changes: 70 additions & 0 deletions app/GraphQL/Social/Mutations/UsersLists/UsersListsManagement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Social\Mutations\UsersLists;

use Kanvas\Apps\Models\Apps;
use Kanvas\Social\Messages\Models\Message;
use Kanvas\Social\UsersLists\Actions\CreateUserListAction;
use Kanvas\Social\UsersLists\DataTransferObject\UserList;
use Kanvas\Social\UsersLists\Models\UserList as ModelUserList;
use Kanvas\Social\UsersLists\Repositories\UserListRepository;

class UsersListsManagement
{
public function create($rootValue, array $req): ModelUserList
{
$userList = new UserList(
app(Apps::class)->id,
auth()->user()->getCurrentCompany()->id,
auth()->user()->id,
$req['input']['name'],
$req['input']['description'],
$req['input']['is_public'],
$req['input']['is_default']
);

$createUserList = new CreateUserListAction($userList);

return $createUserList->execute();
}

public function update(mixed $rootValue, array $req): ModelUserList
{
$userList = UserListRepository::getById($req['id'], auth()->user());

$userList->update($req['input']);

return $userList;
}

/**
* delete
*/
public function delete(mixed $rootValue, array $req): bool
{
$userList = UserListRepository::getById($req['id'], auth()->user());

return $userList->delete();
}

public function addToList(mixed $rootValue, array $req): bool
{
$userList = UserListRepository::getById($req['users_lists_id'], auth()->user());
$message = Message::getById($req['messages_id']);
$userList->items()->attach($message);

return true;
}

public function removeFromList(mixed $rootValue, array $req): bool
{
$userList = UserListRepository::getById($req['users_lists_id'], auth()->user());
$message = Message::getById($req['messages_id']);

$userList->items()->detach($message);

return true;
}
}
3 changes: 3 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Kanvas\Companies\Observers\CompaniesObserver;
use Kanvas\Social\Messages\Models\UserMessageActivity;
use Kanvas\Social\Messages\Observers\UserMessageActivityObserver;
use Kanvas\Social\UsersLists\Models\UserList;
use Kanvas\Social\UsersLists\Observers\UsersListsObserver;
use Kanvas\Users\Models\Users;
use Kanvas\Users\Observers\UsersObserver;

Expand All @@ -35,6 +37,7 @@ public function boot()
Companies::observe(CompaniesObserver::class);
CompaniesGroups::observe(CompaniesGroupsObserver::class);
UserMessageActivity::observe(UserMessageActivityObserver::class);
UserList::observe(UsersListsObserver::class);
}

/**
Expand Down
Loading

0 comments on commit a77d916

Please sign in to comment.