-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from bakaphp/boards
- Loading branch information
Showing
19 changed files
with
777 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/GraphQL/Social/Mutations/UsersLists/UsersListsManagement.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.